Skip to content

It should be possible to execute PowerShell Script Runner dialog and get script result back as dialog value #1336

@AdamNaj

Description

@AdamNaj

Expected Behavior

Show-ModalDialog -Control "PowerShellRunner" `
    -Parameter @{
        id="{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}";
        db="master";
        lang="en";
        ver="1"
        scriptId="{16670A5E-AA62-4EE2-A9C3-C8466BEB45C2}"
        scriptDb="master"
    }

Should return "yes" or "no" based on what the response for the dialog was.

Also usable from C#:

private void Method(ClientPipelineArgs args)
{
    if (args.IsPostBack)
    {
        if (args.HasResult)
        {
            string scriptResult = args.Result?.ToLower();
            if (scriptResult == "yes")
            {
                // Do something
            }
        }
    }
    else
    {
        var str = new UrlString(UIUtil.GetUri("control:PowerShellRunner"));
        str.Append("id", dataItem.ID.ToString());
        str.Append("db", dataItem.Database.Name);
        str.Append("lang", dataItem.Language.Name);
        str.Append("ver", dataItem.Version.Number.ToString(CultureInfo.InvariantCulture));
        str.Append("scriptId", scriptItem.ID.ToString());
        str.Append("scriptDb", scriptItem.Database.Name);
        dialogUrl = str.ToString();
        SheerResponse.ShowModalDialog(dialogUrl, true);
        args.WaitForPostBack();
    }
}

The last not empty line is used as the result.

Metadata

Metadata

Assignees

Labels

area-platform💪 improvementExtra sugar and spice.🤩-release-highlightExciting change that should be highlighted in the release notes and celebrated by SPE fans.
No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions