0

I'm trying to convert a list custom action containing a modal dialog to an spfx extension to make it work on modern list.

The custom action open a SP.UI.ModalDialog and call an aspx page inside to do some actions while sending some custom arguments that will then be used by another js script on the page, and then wait for a callback from the dialog

Here's the code calling the dialog for the custom action

    var dialogArgs = {
                WebServerRelativeUrl: _spPageContextInfo.webServerRelativeUrl,
                ListId: SP.ListOperation.Selection.getSelectedList(),
                ItemsSelected: SP.ListOperation.Selection.getSelectedItems(),
                ParentFolderLeafUrl: url
            };

            SP.UI.ModalDialog.showModalDialog({
                width: 800,
                height: 250,
                url: getSite + '[LinkToTheAspxPage]?Source=' + url,
                dialogReturnValueCallback: function (dialogResult) {
                    if (
                        dialogResult === SP.UI.DialogResult.OK
                        ||                  
                        !localStorage.getItem('SPCopyPaste_DataStorage')
                    ) {
                        
                        window.location.href = fullSourceUrl;
                    }
                },
                args: dialogArgs
            });

and here's the one that will get the arguments sent in dialogArgs in the page

    function WaitingFor_DialogArgs() {
        var _dialogArgs = SP.UI.ModalDialog.get_childDialog().get_args() || undefined;
        if (_dialogArgs) OnPageLoad_WithDialogArgs(_dialogArgs)
        else setTimeout(WaitingFor_DialogArgs, 50);
    }

Now I'm trying to convert everything to a spfx extension, but I've learned that SP.UI.ModalDialog doesn't work on the modern UI. How can I achieve the same results ? I've looked at how to use spdialog and ui fabric, but I can't find a way to send custom arguments or wait for a callback from the dialog. I also have no idea how to get those arguments from the aspx pages after

Thanks in advance for the help and sorry for the bad english

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.