Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a Service Process Flow to expose the Process Flow. 

  2. Know the Name of the Service Process Flow.

    Note

    The "AddToList Work Flow" Service Process Flow ships with Aptify.

    Code Block
    languagejs
    linenumberstrue
    var addToListProcessFlow = "AddToList Work Flow";
  3. Populate the Input Properties – refer to the Process Flow itself for what Input Properties are required. Input Properties in the Aptify JavaScript API are created as properties of a JavaScript object, with the names of the properties matching the names of the Process Flow's Input Properties.

    Image RemovedImage Added

    Code Block
    languagejs
    linenumberstrue
    var addToListInputProperties = {
    	EntityName: "Persons",
    	ViewID: 14008, // ID of a View on Persons
    	SelectedList: 3148, // ID of a List with Entity = Persons, can be multiple IDs comma-separated
    	SelectedRows: "1834,975,1087" // IDs of the selected Persons in the View, can be multiple IDs comma-separated
    	IncludeAllRecords: 0,
    	PromptData: undefined // If a prompt view, pass prompt data here; if not, use undefined
    };
  4. Define success and error callback functions. Of course, you can define these anonymously in the actual call to execute(), but that call will be more succinct and readable if you define them separately.

    Note

    Define only one success function and one error function, even if your process flow has multiple success Result Codes.

    Code Block
    languagejs
    titleDefine A Success Callback
    linenumberstrue
    function _onAddToListSuccess(result) {
    	var resultCode = result.resultCode;
    	// result also contains processFlowName and contextProperties as properties
     
    	// This method is called for all Result Codes for which IsSuccess is true.
    	// Use a switch statement to act on individual Result Codes.
    	switch (resultCode.toLowerCase()) {
    		case "success":
    			// Do processing for SUCCESS Result Code here
    			break;
    		default:
    			Aptify.framework.exceptionManager.publish("Unsupported Result Code " + resultCode + 
    													  " for Process Flow " + result.processFlowName + ".");
    			break;
    	}
    } 
    Code Block
    languagejs
    titleDefine An Error Callback
    linenumberstrue
    function _onAddToListError(result) {
    	var error = result.error;
    	// result also contains processFlowName as a property
     
    	// Do failure/error handling here.
    	// Note that result does NOT include resultCode in the error
    	// case, so you cannot handle different errors differently
    	// unless you parse information out of result.error.
    	
    	// If you have no special error handling to do, 
    	// it is best practice to publish the error.
    	Aptify.framework.exceptionManager.publish(error);
    }
  5. Call Aptify.framework.processFlows.execute() to execute the Process Flow.

    Note

    Best practice is to check that Aptify Web is actually online before making the call, since the Process Flow is executed on the server side.

    Code Block
    languagejs
    titleExecute A Service Data Object
    linenumberstrue
    if (Aptify.framework.utility.online()) {
    	Aptify.framework.processFlows.execute({
    		processFlowName: addToListProcessFlow,
    		inputProperties: addToListInputProperties,
    		success: _onAddToListSuccess,
    		error: _onAddToListError
    	});
    }
    else {
    	// Handle offline condition
    }

...