Class AppianSmartService
java.lang.Object
com.appiancorp.suiteapi.process.framework.AppianSmartService
Abstract class to extend when creating a custom smart service.
Input parameters are defined by using Java bean setters, with an optional getter.
Output parameters are defined by using a Java bean getter, without an explicit setter.
The name of the input/output parameter is defined as either the name of the bean, or the value
of the @Name
annotation. Additional options, such as required-ness, can be
overridden using the @Input
annotation.
When the smart service is executed, the implementation in the run
method will be executed.
Sub-classes must only provide one constructor; that constructor can take any combination of Appian services,
as well as SmartServiceContext
.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.It is not possible to create a node output dynamically at design time.void
onSave
(MessageContainer messages) Invoked when an attended form is saved.abstract void
run()
Override this method to provide the main logic for the custom smart service.void
setDynamicInputs
(List<? extends NamedTypedValue> inputs) Dynamic inputs, those added by the designer using the New Node Input functionality in the UI, can be used by the smart service by overriding thesetDynamicInputs
method.void
setProcessIdStartedFrom
(Long processIdStartedFrom) void
validate
(MessageContainer messages) Override with custom validation logic to validate the inputs and any other pre-requisites to ensure a successful completion of the smart service.
-
Field Details
-
START_PROCESS_FROM_PORTAL
- See Also:
-
START_PROCESS_FROM_PORTAL_TRUE
- See Also:
-
-
Constructor Details
-
AppianSmartService
public AppianSmartService()
-
-
Method Details
-
setDynamicInputs
Dynamic inputs, those added by the designer using the New Node Input functionality in the UI, can be used by the smart service by overriding thesetDynamicInputs
method. The body of the method could, for instance, be used to store the inputs into a member variable that can then be used in the body of the run implementation.- Parameters:
inputs
- the inputs on the data tab of the node that were added by the model designer. This parameter is populated by the process execution layer for classes that extend AppianSmartService.
-
getDynamicOutputs
Deprecated.It is not possible to create a node output dynamically at design time.Dynamic outputs, those that aren't defined as getter methods in the smart service that extends AppianSmartService, can be dynamically created by logic in the smart service implementation in therun
method and added to the runtime results by callinggetDynamicOutputs().add()
. Any output added in this way must match the name of a node output created dynamically at design time in order for the value to be available for output mapping. -
validate
Override with custom validation logic to validate the inputs and any other pre-requisites to ensure a successful completion of the smart service. This method is always invoked for attended and unattended activities prior torun()
. If the logic of the method adds any errors to theMessageContainer
, the node will fail to complete and the errors will be displayed to the user (in the case of an attended node) or displayed in the alert (in the case of an unattended node).- Parameters:
messages
- theMessageContainer
that will hold the error messages displayed as the result of failed validation. The parameter is provided by the process execution layer.- See Also:
-
onSave
Invoked when an attended form is saved. Like thevalidate
method, this method allows for logic to validate inputs or other pre-requisites. Unlikevalidate
, this is only invoked on attended activities when the user chooses to save the form instead of submitting it. Only override this method if there are strict reasons why a form cannot be saved with invalid values in the inputs. From a usability perspective, it is preferable to allow a user to save a form in an invalid state instead of preventing the save with validation messages.- Parameters:
messages
- theMessageContainer
that will hold the error messages displayed as the result of failed validation. The parameter is provided by the process execution layer.- See Also:
-
run
Override this method to provide the main logic for the custom smart service. Therun
method is invoked when the node is executed, after calling all setters and thevalidate
method. Throw a SmartServiceException in the body of your method to indicate that the smart service should fail to complete. Note: no automatic cleanup will be conducted, so if your smart service changed the state of persisted data before throwing the exception, that change will remain.- Throws:
SmartServiceException
- See Also:
-
setProcessIdStartedFrom
- Parameters:
processIdStartedFrom
-
-
getProcessIdStartedFrom
- Returns:
- the id of the process that started this smart service
-