08-13-2015 02:46 PM
Quoting the accepted answer on this post (https://www.onbase.com/community/technical_communities/onbase_apis/f/10815/t/21344😞
Unity API scripting is available either through C# or VB.NET, and you can refererence libraries such as System.Windows.Forms so displaying a message box or even more intricate UI is no problem.
I have attempted to write a C# Unity script that would launch when the user clicks an Action Button, display a MessageBox to the user, allow them to press Yes or No, then capture that result, and perform certain actions based on which button was clicked.
I have added a reference to System.Windows.Forms to my script and my code is below, which compiles without errors.
When I click the Action Button, the script launches, but the message box with Yes/No never appears. The message box that appears says "You did not click Yes or No." As you can see in my code below, that one pops up if we do not detect a valid DialogResult.
I will note that I have tried all the different values for the MessageBoxOptions parameter, without success.
public void OnWorkViewExecuteActionButtonScript(Hyland.Unity.Application unityApplication, Hyland.Unity.WorkView.WorkViewExecuteActionButtonScriptEventArgs args)
{
try
{
DialogResult dr = MessageBox.Show(
"Are you sure you want to do this?",
"Action Confirmation",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.ServiceNotification
);
if (dr == DialogResult.Yes)
{
args.AddUIActionMessageBox("You clicked Yes.");
return;
}
else if (dr == DialogResult.No)
{
args.AddUIActionMessageBox("You clicked No.");
return;
}
else
{
args.AddUIActionMessageBox("You did not click Yes or No.");
return;
}
}
catch (Exception ex)
{
unityApplication.Diagnostics.Write(ex.Message);
args.AddUIActionMessageBox("Error Message: " + ex.Message + " \n Source: " + ex.Source + " \n StackTrace: " + ex.StackTrace );
}
}
08-13-2015 02:59 PM
Hi Sam,
Server-side scripts wil not display dialogs on the user workstation. In order to display a MessageBox to the user, the script has to be running client-side. Creating a script as IClientWorkflowScript will allow it to be run from the Unity Client as a client-side execution. I tested this in v15.0.1.84, and it works as expected.
EDIT: After I posted this, I also went back and tested a two-part process with a second prompt relying on the results of the first:
This also works as expected in the Unity Client
Hope that helps.
Kind regards,
Scott
08-13-2015 02:54 PM
I seem to recall working with MessageBoxes in Unity Scripts a while ago and ran into a similar issue. I believe what was going on is that since the script is actually executing on the AppServer, the MessageBox that is waiting for user input is being displayed on the server instead of locally to the user.
It's just a thought, can anyone maybe expand on this?
08-13-2015 02:59 PM
Hi Sam,
Server-side scripts wil not display dialogs on the user workstation. In order to display a MessageBox to the user, the script has to be running client-side. Creating a script as IClientWorkflowScript will allow it to be run from the Unity Client as a client-side execution. I tested this in v15.0.1.84, and it works as expected.
EDIT: After I posted this, I also went back and tested a two-part process with a second prompt relying on the results of the first:
This also works as expected in the Unity Client
Hope that helps.
Kind regards,
Scott
08-13-2015 03:02 PM
Code-wise, I did the following:
1. Create my script as IClientWorkflowScript
2. Add a reference and using directive to System.Windows.Forms
3. Called MessageBox.Show()
I assigned the client-side script to an ad hoc task and executed it in the Unity Client.
The MessageBox appeared as expected.
Programmatically, this is basically identical to what you're doing, except I am executing a client-side script.
08-13-2015 03:18 PM
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.