In the CustomActionShared.zip archive there are two files:
1) Upload sbExecuteCustomLogicConfiguration.txt to Site Assets/sbSharedAction.
2) In Site Assets document library, sbSharedActions folder create sbExecuteCustomLogic folder with Scripts subfolder.
3) Upload sbExecuteCustomLogic.js to sbExecuteCustomLogic/Scripts.
There is a stub in sbExecuteCustomLogicExecutor in sbExecuteCustomLogic.js:
Just place your custom code inside this function body.
If you would like to have an advanced configuration for your custom action in Action Builder like in out of the box skybow Actions, please follow the next steps.
In the script you will find the Message property configured for the action. It is possible to add other properties and assign values or Expressions to them.
1) Provide template. In this step it is needed to set the HTML template with the inputs and bindings for the properties. (For more information on template and bindings please visit https://knockoutjs.com/).
In the sbExecuteCustomLogic.js find CustomActionConfigVM.prototype.LoadTemplate:
- In the template, there is a table row (<tr>) that represents the input for the property.
- Also data-bind attribute specifies the binding of this input to the Message property.
- this.MapPropertyToObservable('Message'); - specifies the binding logic.
2) To provide the evaluation of the properties in CustomActionExecutor.prototype.ExecuteAction:
- Specify all the properties names in props array. The names of the properties should be the same as the ones specified in the previous step.
- evaluatedValues – object that stores all the evaluated properties values. Now it is possible to retrieve the value using evaluatedValues[“PROPERTY_NAME”] syntax and pass them as parameters to the CustomActionExecutor.prototype.ExecuteActionInternal function. You can modify the number of arguments of this function to match your properties set or pass the whole object and then access properties via [“PROPERTY_NAME”] in function body to execute your custom logic.