Custom Action
Custom Action is the most widely used SDK extension, and a huge amount of functionality can be implemented with it.
The sdk actions can be used wherever standard actions e.g. on a path transition or on a menu button.
The most popular applications are:
- Communication with webservices
- Database operations
- Generating/modifying attachments
- Changing form field values
Examples of SDK actions are available on our GitHub, for a list of all examples see Examples. Everything you need to create an SDK and how to create a project is described int the Create extensions in VS article.
Operation of the SDK Custom Action
Two methods are crucial to the operation of SDK Custom Action:
- Task RunAsync(RunCustomActionParams args)
- Task RunWithoutDocumentContextAsync(RunCustomActionWithoutContextParams args)
RunAsync
When you create a new action using our templates, a RunAsync method will be generated by default. This is the method that will be called by the BPS when the action is triggered, the entire execution of the add-on begins with it. This method will be called if the action is invoked from within the BPS Portal, such as using a menu button, on timer or on a user-initiated path transition.
In the RunCustomActionParams parameter, data related to the context of the action are passed, e.g. current document on which the action has been run or methods for logging or returning messages to the user.
public override Task RunAsync(RunCustomActionParams args)
{
throw new NotImplementedException();
}
RunWithoutDocumentContextAsync
If action is not invoked by BPS Portal but BPS service then RunWithoutDocumentContextAsync will be called instead. This will happen when the action is used as a global cyclical action. In this method, there is no access to the document context because the call is not associated with any document. Therefore, instead of RunCustomActionParams, RunCustomActionWithoutContextParams is passed to this method.
public override Task RunWithoutDocumentContextAsync(RunCustomActionWithoutContextParams args)
{
return base.RunWithoutDocumentContextAsync(args);
}