PL 400: create, manage, and interact with business process flows by using server-side and client side code(Implement processes)

The business process flow provides a visual guide to the end user through a defined process to accomplish multi-step tasks. Generally, organizations have complex and lengthy processes to complete tasks which leads to mistakes and time consumes the time of the user. But the business flow process aligns those tasks and creates a visual sequence of tasks to make it easier for the end users.


As such, Microsoft recommends using the Visual Business Process Flow Designer to define business process flows, they provide limited capabilities for updating business process flows with constraints. By default, a business process flow record is created in the draft state and its definition is stored in the workflow entity and the stage information for the business process flow is stored in the processstage entity.

The custom business process flow entity has Organization scope.

For the create, retrieve, update and delete, user needs the privileges and these permissions provide according to role based. System Administrator and System Customizer roles are granted access by default. The custom entity supports the standard programmatic creation and management of records (process instances) using Web API and CRM 2011 endpoint.

Using the Web API:

Request:

GET [Organization URI]/api/data/v9.1/workflows?$filter=name eq 'User defined BPF'&$select=uniquename HTTP/1.1

Response:

{  
"@odata.context":"[Organization URI]/api/data/v9.1/$metadata#workflows(uniquename)",
"value":[  
     {  
         "@odata.etag":"W/\"1084677\"",
         "uniquename":"new_mycustombpf",
         "workflowid":"2669927e-8ad6-4f95-8a9a-f1008af6956f"
     }
  ]
}


Using the Organization service:

QueryExpression query = new QueryExpression
{
    EntityName = "workflow",
    ColumnSet = new ColumnSet("uniquename"),
    Criteria = new FilterExpression
    {
        Conditions =
        {
            new ConditionExpression
            {
                AttributeName = "name",
                Operator = ConditionOperator.Equal,
                Values = { "User defined BPF" }
            }
        }
    }
};
Workflow Bpf = (Workflow)_serviceProxy.RetrieveMultiple(query).Entities[0];

Client Side Code:

formContext.data.process Provides access to the business process flow. To get and set the active process, the developer must use the getActiveProcess and setActiveProcess methods. Under Objects, there are several objects that use as collections. formContext.data.process provides events, methods, and objects for interacting with business process flow data on a form.

//Get active process details 
var activeProcess = formContext.data.process.getActiveProcess(); 
var getActiveProcessName = activeProcess.getName();  
//Get active Stage details 
var activeStage = formContext.data.process.getActiveStage(); 
var getactivestagename = activeStage.getName();  
var state = formContext.getAttribute("statecode").getValue(); 

Important Links:

 Business Process flow (Client API reference)
Business Process flow (Programmatically)

Comments

Popular posts from this blog

Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse

PCF vs. Web Resources: Choosing the Right Extensibility Tool for Dataverse

Effective Strategies for Debugging Plugins in Dynamics CRM