If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Creating Service Process Flows

Service process flows (SPFs) provide the ability to execute process flows from Aptify Web and Aptify SOA, returning the Result Code and Output Properties of the Process Flow to the caller.  Process flows in Aptify are used to define business logic in metadata.  They are built with components, scripts and other Process Flows, connected with branching logic.  A Visual Designer is used to build Process Flows.  The ability to securely execute Process Flows through Aptify SOA is another powerful development tool for application developers and integrators.

SPFs identify the process flows that can be executed and by whom.  A Service Process Flow is called by the Name of the Service Process Flow, which does not have to match the name of the Process Flow.  Aptify SOA looks up the Service Process Flow, confirms that the current platform and User are allowed to execute the Service Process Flow, executes the Process Flow and returns the Process Flow’s Result Code and Output Properties.

How to Create Service Process Flow

  1. Create a Process Flow or identify an existing Process Flow that should be available via Aptify SOA.  See Create A Service Process Flow for more information on creating process flows.  In this example, the AddToList Work Flow Process Flow will be made available as a Service Process Flow.

    As of Aptify 5.5.4, the following requirements apply to Service Process Flows:

    Service Process Flows must be associated with a Service Application.

    When you create or update a Service Process Flow, you must restart Web Services for the changes to be incorporated into the system.



  2.  Create a new Service Process Flows record: 


    The Name of the Service Process Flow will be used as an input to the Service Process Flows endpoint.  Process Flow links the Process Flow that will be executed when the Service Process Flow is called.
     

  3. Applying Application Filters:  Enable Application Filters is a Boolean field. You can specify which applications you want to allow accessing Service Process Flow. For example, our Service Process flow object can only be called within the HTML5 Web Application.



  4. Applying Security: Enable Security is a Boolean field which will consider Security setting for the current Service Process Flow.  The security settings give you an ability to permit Users, Groups or WebGroups.  Users and Groups apply to Aptify Users.  Web Groups apply to Web Users.  What is defined here will be based on the Authentication Provider used for the Application.  In this example, only the User ‘sa’ can execute the Service Process Flow. (The sa user’s ID is 11 in the example below.)



  5. Calling the Service Process Flow from Aptify SOA: To execute a Service Process Flow using Aptify SOA, use the Process Flow endpoint:

    https://<serverbase>/services/ProcessFlow/{sProcessFlowName}
    Sample Service Process Flow Example
    https://<serverbase>/services/ProcessFlow/Execute Match Import Run Details
  • This endpoint executes a process flow. The process flow parameters should be passed as POST data. This service will return an http error code if the process flow is not found, if the user does not have the authority to execute the process flow, or if required input parameters are missing. If the process flow exits successfully with a failed result, an OK http code will be returned for the response. The results of the process flow will be returned as json data.

  • This Process flow expects following parameter:

    Parameter NameQuery Param?TypeExample
    ImportRunIDYesLong1
    Sample Response Body
    {
    	"serviceProcessFlowName":"Execute Match Import Run Details",
        "result":
    			{
    			 "isSuccess":false,
                 "resultCode":"", 
                 "errorMessage":"", 
                 "userErrorMessage":""
                 },
        "contextProperties":
                           [{
                              "name":"ImportRunID",
                               "value":"1"
                           }]
    }

    Calling a Service Process Flow from the Aptify JavaScript API:  The following code illustrates how to call a current Service Process flow using the Aptify JavaScript API.

     

    Sample Javascript Code
    var p = Aptify.framework.processFlows;
     
     if (p) {
    	 p.execute({
    		 processFlowName: "AddToList Work Flow",
    		 inputProperties: {
    				 EntityName: listParams.EntityName,
    				 ViewID: listParams.ViewID,
    				 SelectedList: listParams.ListIDs.join(","),
    				 SelectedRows: listParams.RecordIds.join(","),
    				 IncludeAllRecords: listParams.IncludeAllRecords,
    				 //Anil B for issue 15467 on 04/02/2014
    				 //Pass prompt view data to process flow.
    				 PromptData: listParams.PromptData
    		 },
    		 success: function (ev) {
    		 // add any other logic which you want to be executed after Service Data Object 
    		 // successful execution. 
    	 },
    	 error: function (ev) {
    		 // Handle error or add any other custom logic which you want to be executed after
    		 // Service Data Object execution failed.
    	 }
     });
     }

Here p is the JavaScript variable where we are the initializing the Aptify.framework.ProcessFlows object. The p.execute is a JavaScript function which takes Service Process Flow Name and Input Properties as input, success callback function, error callback function.  If the Process Flow Result Code indicates success, the success callback function will be executed.  If the Process Flow Result Code indicates failure, the error callback function will be executed. 


Copyright © 2014-2019 Aptify - Confidential and Proprietary