dheeraj kumar

dheeraj kumar

  • NA
  • 4
  • 3.2k

use SP.UI.Modaldialog.showDialog(options); in spfx extension

Apr 9 2020 8:23 AM
Hi I'm trying to open sharepoint dialog using spfx extension in which using typing able to get the SP.UI.ModalDialog Object in ts file of the extension.
 
And the code #
 
SP.UI.ModalDialog.showModalDialog(options);
 
executes completely without any error. But unfortunately no dialog is visible. below is the onexecute Method of the extension.
 
public onExecute(event: IListViewCommandSetExecuteEventParameters): void
{
switch (event.itemId)
{
case 'COMMAND_1':
//Dialog.alert(`${this.properties.sampleTextOne}`);
let ele = document.createElement('div');
let options =
{
title: "My Dialog Title", width: 400, height: 300, url: "https://*****.sharepoint.com/sites/***/home.aspx" }; //
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
SP.UI.ModalDialog.showModalDialog(options);
break;
case 'COMMAND_2': Dialog.alert(`${this.properties.sampleTextTwo}`);
break;
default: throw new Error('Unknown command'); }
}
 
Any idea why the sharepoint dialog is not visible, i m trying this on modern site. Any help is highly appreciated.