Hands on 9 – creating reusable processes using an invocable process

Invocable processes can call one process from another process. Using invocable processes, you can reuse sections of your processes. You can create an invocable process and call it from multiple processes, or from multiple action groups in the same process. You can invoke processes with objects that share at least one unique ID.

For example, in the Opportunity and Quote objects, the OpportunityID field is unique to Opportunity, and is also used by Quote. You can create an invocable process that updates an Opportunity record. Then, you can invoke it from the following:

  • A process that updates an Opportunity record
  • A process that updates a Quote record

When you create a process, make sure that you start it when another process invokes it, by selecting It’s invoked by another process.

Let's look at a business scenario. Suppose that Alice Atwood is working as a system administrator at Universal Containers. She has received a requirement from the management to automate the sales process a bit; that is, if a quote is denied by a customer, then a process should auto-update the opportunity to Closed Lost.

There are numerous methods to solve the preceding business requirement, including the following:

  • Process Builder
  • Visual Workflow and Process Builder
  • Visual Workflow and inline Visualforce page
  • Apex trigger

We will use an invocable process to solve this business requirement. We will have to create two processes for this, as follows:

  • The first process (It’s invoked by another process) is placed on the Opportunity object, to update the Stage to Closed Lost.
  • Another process (A record changes) is placed on the Quote object, and it will fire only when the quote status is updated to Denied.

The benefit of using this approach is that if you get a future requirement to update the opportunities stage to Closed Lost when the account Active field is updated to false, then you can call this process from your account process without adding another record update.

Perform the following steps to solve the preceding business requirement:

  1. Navigate to Setup (gear icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder, click on the New button, and enter the following details:
    • Name: Enter the name of the process -Update Opportunity Stage.
    • API Name: This will be auto-populated, based on the name.
    • Description: Write some meaningful text, so that other developers or administrators can easily understand why this process was created.
    • This process starts when: Configure the process to start when a record is created or edited. In this case, select It’s invoked by another process.
  2. Once you are done, click on the Save button. It will redirect you to the process canvas, which will allow you to create or modify the process.
  3. After Define Process Properties, the next task is to select the object upon which you want to create a process and define Evaluation Criteria. For this, click on the Add Object node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the Object. Start typing, and then select the Opportunity object. A window will appear, as shown in the following screenshot:
    1. Once you are done, click on the Save button.
      1. After defining the Evaluation Criteria, the next step is to add the Process Criteria. Once the process criteria are true, the process will execute the associated actions. To define the process criteria, click on the Add Criteria node. It will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
        • Criteria Name: Enter a name for the criteria node - Only for open opportunity.
        • Criteria for Executing Actions: Select the type of criteria that you want to define. You can select Formula evaluates to trueConditions are met (a filter to define the process criteria), or No criteria-just execute the actions! In this case, select Conditions are met.
        • Set Conditions: This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions. In this case, select [Opportunity].StageName Does not equal Closed Won.
        • Conditions: In the Conditions section, select All of the conditions are met (AND). This field lets you specify which combination of the filter conditions must be true for the process to execute the associated actions.

      It will appear as follows:

      1. Once you are done, click on the Save button.
        1. Once you are done with the Process Criteria node, the next step is to add an Immediate Action to update the opportunity stage to Closed Lost. For this, we will use the Update Records action in Process Builder. Click on Add Action available under IMMEDIATE ACTIONS; it will open an additional window on the right-hand side of the process canvas screen, where you will have to enter the following details:
          • Action Type: Select the type of action; in this case, select Update Records.
          • Action Name: Enter a name for this action. Enter Stage to Closed Lost as the Action Name.
          • Record Type: Select the record (or records) that you need to update. Click on the Record type, and it will open a window, where you will have to select Select the Opportunity record that started your process.
          • Criteria for Updating Records: Optionally, you can specify conditions to filter the records that you are updating. In this case, select No criteria—just update the records!
          • Set new field values for the records you update: Select the field whose value you want to set. In this case, set the Stage field to Closed Lost

        The preceding steps will look as follows:

        1. Once you are done with the process creation, the final step is to activate it. To activate the process, click on the Activate button on the button bar. Finally, the process will appear, as shown in the following screenshot:

        The next step is to create another process (A record changes) on the Quote object; it will fire only when the quote status is updated to Denied, and will call the process that we just created.

        ..................Content has been hidden....................

        You can't read the all page of ebook, please click here login for view all page.
        Reset
        18.118.193.7