Command

This component is used to display a button that will execute a command/event/wizard specified in the field definition or a button from the command bar. The button to execute the command/event/wizard will only be displayed if the command/event/wizard can be executed in the form’s currents state. 

Component Code

The first section contains the standard parameters and the few variables used by the component. Below are the various methods used by the component.

OnInitializedAsync()

This method is called to initialize the component. Its purpose is to subscribe to the OnFieldChange event and call FieldUpdated when it’s invoked. This is to adjust the visibility of the button when replicating a command bar button.

FieldUpdated()

This method is called when the OnFieldChange event is invoked. Its purpose is to re-assign all variables used when replicating a command bar button and refresh the state of the component.

IDisposable.Dispose()

This method is called when the component is disposed. Its purpose is to unsubscribe from the OnFieldChange event.

OnParametersSetAsync()

This method is called after the component has initialized and anytime there’s an update to its parent component. It’s purpose is to assign values to variables and call the correct setup method depending on the Action Type.

SetupCommandBarAction()

This method is called to setup the command bar action button. Its purpose is to assign all variables related to the command bar button.

ExecuteCommandBarAction()

This method is called when the button is selected and it’s replicating a command bar button. Its purpose is to call the correct execution method.

SetupCommandEventWizard()

This method is called to setup the command/event/wizard button. Its purpose is to assign values to the required variables and validate the command/event/wizard can be executed.

ExecuteCancelAction()

This method is called when the button is selected and it’s replicating the Cancel button from the command bar. Its purpose is to discard all unsaved changes and return to the previous instance.

ExecuteSaveAction()

This method is called when the button is selected and it’s replicating the Save button from the command bar. Its purpose is to save all pending changes on the instance.

ExecuteReloadUndoAction()

This method is called when the button is selected and it’s replicating the Reload/Undo button from the command bar. Its purpose is to either reload the current instance or undo all unsaved changes.

ExecuteDoneAction()

This method is called when the button is selected and it’s replicating the Done button from the command bar. Its purpose is to save all pending changes and return to the previous instance.

GoToPreviousInstance()

This method is called when trying to move the user to the previous instance. Its purpose is to do the the parent instance if in a popup window or load the previous instance in the users instance history.

CallCommandEventWizard() 

This method is called when the command/event/wizard button is selected and attempts to execute the command/event/wizard. 

To execute, there’s a check to see if a confirmation dialog should be displayed.

The next step is to ensure the instance has no validation errors (all required fields are populated etc.). Next the command/event/wizard is executed, if it’s a command or event being executed then after execution process, the instance is reloaded to properly capture any possible changes in the user experience the command/event could have caused. If it is a wizard being executed the wizard will appear in a popup window. 

If there are any validation errors or the command/event/wizard fails, the user is notified via a popup notification. 

DisposeWizard(DotNetObjectReference<Wizard> wizardObjRef) 

This method is used to properly dispose the wizard component after it’s been completed or the user has exited the wizard. 

Updated on August 8, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment