Hi all
I have an AS script that expose a URL as result in a UI popup, as the script is executed inside the LCA
UIBuilder uib = new UIBuilder();
UIBlockDefinition link = new UIBlockDefinition();
link.Type = UIBlockType.DownloadButton;
link.ConfigOptions = new AutomationDownloadButtonOptions()
{
Url = "https://url",
StartDownloadImmediately = false,
FileNameToSave = "",
ReturnWhenDownloadIsStarted = true,
};
link.Title = "link";
uib.AppendBlock(link);
UIResults res = new UIResults();
do
{
res = engine.ShowUI(uib);
} while (!res.WasOnDownloadStarted("link"));
I setted the url as Download button so the user is able to click on it and the new webpage will be opened, I also need to add the do block so the popup stay opened so the user can click on it.
But how I can let the popup auto-close when the download start? I tried with WasOnDownloadStarted but it not works
Hi Marco
It should be possible to stop the script when the download button was clicked. The script you've added would need a few changes though.
The identifier of a block definition, that you're using in WasOnDownloadStarted, is stored in the DestVar property, instead of Title. Next to that the RequireResponse property should be set to true, otherwise the script will constantly loop and refresh the UI.
Could you update the script as follows and let me know if this works for you?
UIBuilder uib = new UIBuilder();
uib.RequireResponse = true;
UIBlockDefinition link = new UIBlockDefinition();
link.DestVar = "link";
// …
Small note: the URL will need to remain available after the script was stopped, because the download could still be busy. For instance, for a file located in the Documents module.