Class AppianSmartService

java.lang.Object
com.appiancorp.suiteapi.process.framework.AppianSmartService

public abstract class AppianSmartService extends Object
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:
  • Constructor Details

    • AppianSmartService

      public AppianSmartService()
  • Method Details

    • setDynamicInputs

      public 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 the setDynamicInputs 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 public List<NamedTypedValue> 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 the run method and added to the runtime results by calling getDynamicOutputs().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

      public 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. This method is always invoked for attended and unattended activities prior to run(). If the logic of the method adds any errors to the MessageContainer, 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 - the MessageContainer 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

      public void onSave(MessageContainer messages)
      Invoked when an attended form is saved. Like the validate method, this method allows for logic to validate inputs or other pre-requisites. Unlike validate, 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 - the MessageContainer 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

      public abstract void run() throws SmartServiceException
      Override this method to provide the main logic for the custom smart service. The run method is invoked when the node is executed, after calling all setters and the validate 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

      public void setProcessIdStartedFrom(Long processIdStartedFrom)
      Parameters:
      processIdStartedFrom -
    • getProcessIdStartedFrom

      public Long getProcessIdStartedFrom()
      Returns:
      the id of the process that started this smart service