Sage CRM 2021: Invoking Workflow from Self Service and Web Service (SOAP) Based Applications

1 minute read time.

One of the challenges that a developer will face when working with Self Service or with an external Application using the SOAP Web Services interface is that workflow is not fully covered by the APIs.

Self Service and Workflow

Self Service uses the COM API and is designed for use in ASP pages. Please see the article "ASP.NET Pages and the Self Service API".

As part of the COM API Self Service can create insert records and attached those newly created records to an existing workflow. See the article "Creating and Controlling an Insert Page in Self Service".

But Workflow as a concept within Sage CRM is mostly 'User' rather than 'Visitor' focussed. So Self Service does not have an simple API option to move existing records on through a workflow.

But because it is a COM API we could use the same technique that is used when designing ASP pages that are called by Workflow for the main user interface. Please see the article "Controlling workflow state in ASP".

Web Services and Workflow

The SOAP based Web Services do not cover Workflow. This has been discussed previously in the article "Workflow and Web Services".

An Alternative Approach

So how can an external application, either Self Service or Web Service based invoke Workflow like behaviour?

Consider this URL

http://[servername]/[installname]/CustomPages/workflow/progressworkflow.asp?Entity=Project &RecordID=6005 &WorkflowID=14 &NextState=53

This ASP page represents a URI that when called will process the entity and move the workflow to the next stage using the techniques described in the previous articles.

The ASP page could carry out an external log. It doesn't need to create a 'Session' inside Sage CRM. I have discussed the external instantiation of the COM object in the article "Instantiation of the COM (eWare.CRM) object".

The Workflow State could then be forced using code.

var workflowinstanceRecord = CRM.FindRecord 
("workflowinstance","wkin_instanceid="+ProjectRecord.proj_workflowid); 
workflowinstanceRecord.wkin_currentstateid = 53; 
workflowinstanceRecord.SaveChanges();

The ASP page, or application would only need to return "Success" or "Failure" in a simple XML message.


Both Self Service Applications and programs that use Sage CRM Web Services can issue HTTP requests and therefore use this technique to change Workflow state.