LB Services

LB Services is a Logic Builder extension that allows calling flowcharts through the Sugar REST API, from SugarBPM, and from another flowchart.

LB Services extension is needed when you need to call a flowchart from:

  • external system
  • program code (for example, a developer has added a new button to the interface, but the logic that will be executed when the button is clicked needs to be controlled or when an external system sends information to Sugar, but how this information is processed after retrieve can be implemented via Logic Builder)
  • SugarBPM, when part of the process can be a flowchart
  • another flowchart. Let’s say there are a bunch of flowcharts with the same steps to perform an action. Instead of repeating the same steps in each flowchart, it is possible to create a separate flowchart and then call it from other flowcharts.

How to create a new service?

To add new service:

  1. Register it in Sugar
  2. Configure its logic in Logic Builder
  3. Use it!

Register New Service in Sugar

After deploying LB service extension, the new module LB Services is added to Sugar. To register a service, create a new record in this Module:

  • Name – specify the user-friendly name of the service
  • System Name – specify unique name of the service (can contain only symbols [a-z], [0-9], [_], [-])
  • Arguments – specify all arguments that are going to be input to the service (e.g. by an external system or another flowchart) or will be returned as a result of service execution (e.g. to return the result to an external system). In Label part specify a user-friendly argument name, and in part Name – system name, which can contain only symbols [a-z], [0-9], [_], [-]
  • Description – optionally add some words which explain what is this service for.

How to configure service logic in Logic Builder?

The start operator of service logic is On Service Call:

In service name dropdown select the service which logic is described in this flowchart. This dropdown is composed of records in LB Services module from Sugar which metadata is loaded in the Project.

To read service parameters that were input by an external system or other flowcharts use the operator Get Service Parameters. Once service is linked into the input port, select needed parameters from the dropdowns.

To set values for service parameters to be used as a response to a call from an external system or SugarBPM use Set Service Parameters. Input service and then select service arguments which values you would like to set. To set the value simple link it with the appropriate service argument:

To set the result to be used in other flowcharts use Set Service Result. Input service and value that should be in the result port and can be used in other flowcharts:

Combine dedicated to services operators with other others to configure logic.

How to use services?

There are several options for how to use services. Let’s see the following examples.

Example 1: How to use service to call flowchart from another flowchart

Let’s say that there is a step to get a number of related to Account Product Cases, that were registered this month. This number of Cases is used in several flowcharts, so instead of counting this number in each flowchart, let’s create a service that will count this number and then just call this service from the other flowcharts.

Step 1: Register service in Sugar.

In LB Services module we are creating a new record. As an argument we need only one to have an Account ID:

Step 2: Configure logic in Logic Builder

Firstly, right after adding a new service, it is needed to update Sugar Metadata in the Project.

The flowchart starts from On Service Call and in the very first step we are reading the service parameter value to get account_id and retrieve Account by this ID:

Then count a number of cases in a loop:

Finally, put the result (the number of such cases) using Set Service Result:

The flowchart that implements service is ready, deploy it in Sugar instance.

Step 3: Call the flowchart from another flowchart

Now let’s assume that after a Case is linked to an Account it’s needed to evaluate the number of Product Cases registered this month. So instead of building logic to count such Cases, just use Call Service operator to call the corresponding service. In service name dropdown select service and then provide argument values – Account ID in our case. As result there is a number of such Cases:

Example 2: How to use service from an external system or custom code

Let’s say that Lead Status is updated from an external system. But it is needed to evaluate whether the status can be updated prior to actually changing it.

Step 1. Again, register service in Sugar. As service arguments, we have lead_id that should be an input argument and message, that will be filled by the service and returned to the external system.

Step 2. Create a flowchart that implements the service logic. As usual, such flowchart starts from On Service Call. Then read parameters values from the service with Get Service Parameters:

After configuring the logic of whether Lead status can be updated, to return value to the external system use Set Service Parameters:

And deploy flowchart into Sugar instance.

Right after deployment the new REST endpoint will be created in Sugar:

EndpointMethodDescriptionExceptions
POST /lb/services/:serviceNamelbServiceCallCall specific LB Flowchart Service.Not Found, No Service Implementation

Request Arguments

NameTypeDescriptionRequired
argumentsMapInput service parameters passed to the flowchart as key-value pairs, where key is a name of service parameter, and value is a value of service parameter.false

Response Arguments

NameTypeDescription
argumentsMapOutput service parameters returned from the flowchart as key-value pairs.

Endpoint can be used just like the standard Sugar REST API. Documentation is available at: sugarurl/rest/v11_4/help

Example of usage the service to update lead status:

urlhttps://{​​​​​site_url}​​​​​/rest/v11_15/lb/services/update_lead_status
methodPOST
request{​​​​​​​​​​​​​​​​​​​​
    “arguments” : {​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
       “lead_id” : “798cdde8-ff5e-11e7-ab44-000c29996212”
    }​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
response{​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
     “arguments” : {​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
         “lead_id “: “798cdde8-ff5e-11e7-ab44-000c29996212”,
         “message”: “success!”
    }​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Manually calling service

It’s possible to call Service from the Sugar interface.

Please note that this is a real call and service execution, not an emulation.

To manually call the service, open the LB Services record and click the Call Service button:

Then provide input arguments (e.g. Lead ID) and click Execute:

On the right side there are results of service execution:

Note: you can open Developers Console in Browser (commonly F12 button) and then click Execute. That will reveal how service is called:

 Also, services are used to extend SugarBPM processes. Please refer to the documentation for SugarBPM extension. 

Can I Export and Import LB Services records?

Yes, you can migrate LB Services from one Sugar instance to another using the standard Sugar export and import (for example, if you would like to deploy changes from sandbox to production).

 The following fields must be imported:

  • Name
  • System Name – this field is used to map the LB Services record and the flowchart that describes the logic of this service.
  • Arguments – if they were specified for the service

Note: When importing LB Services records between Sugar instances, only the LB Services records are migrated. The logic described in Logic Builder is not migrated. To transfer the logic generated in the Logic Builder, you need to install the appropriate packages on the instance.

Can I apply to LB Services records Role restrictions?

Yes, standard Roles Configuration can be applied to the module LB Services.

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *