Server and Client Methods Events
Each method exposes event triggers that you can use to further configure your form or display.
Server and client methods expose the following event triggers: ExecutedSuccessfully and ExecutedWithError. In addition, if you select the SubscribeToNavigatorSelection source, the following event trigger is exposed: NavigatorSelectionChanged.
After a method executes, one of these events will occur, whether the method is triggered programmatically or via the events specified in the EventTriggers property.
ExecutedSuccessfully occurs if the method completes execution as expected. ExecutedWithError occurs if the method fails to complete as expected. For example, if you call the CreateEquipment method to create an Enterprise resource with an S95Id that is already in use, the CreateEquipment method returns an error stating that the specified name cannot be used and the ExecutedWithError event then occurs.
The Event Triggers dialog box can be accessed from either the EventTriggers property on the Property panel, or by right-clicking a control and selecting Add Event Handler. When you add an event handler, the control's code behind appears.
When adding an event handler for the ExecutedWithError event in code-behind, the exact exception causing the error is available as a parameter. For example, you can write the following code:
private void CreateEnterprisemethod_ExecutedWithError (object sender,
Proficy.Platform.Core.DisplayFramework.Controls.ExecutionErrorEventArgs e)
{
String errorMessageToUser = String.Format ("Oh no!! {0}", e.Exception.Message);
MessageBox.Show(errorMessageToUser);
}
Additionally, when ExecutedWithError occurs, the property LastExecutionError on that method is set to the Exception object. This allows you to use this error without requiring any coding because it will be available in the Binding dialog box for use like any other property. If the method executes again, but this time successfully, LastExecutionError is reset to null. This property is read-only.There are two scenarios for using these events. For each scenario, assume that you have already created two server methods with the Source property set to CreateEquipment: one you have set the S95 Type property to Enterprise and named it Create Enterprise, and the other you have set the S95 Type property to Site and named it Create Site.
Scenario A
You can use these events to raise form events. On the Form Events tab, add two form events: one called ExecuteSuccess to notify the workflow when the method executes successfully, and another called ExecuteFailed to notify the workflow when the method occurs with an error.
When you open the Event Triggers dialog box, the event options, ExecutedSuccessfully and ExecutedWithError are available under each of the server methods.
Scenario B
You can also use these events to chain methods together in the form. Using the Create Enterprise and Create Site methods, you can configure the Create Site method to create the site resource immediately after the enterprise resource, with the new enterprise as the parent. Configure the Create Site method as follows:
- Select the
CreateEnterprise.ExecutedSuccessfully
event trigger. - Select
CreateEnterprise.ReturnValue
as the parent.