Example: Actions performed by the example script

When the escalation runs the action, the action starts the script. The script determines which group the service request is assigned to.

The following script is used to automate the assignment of service requests to service groups:
#Check if the SR is classified as a pipe leakage
if v_srclassif=='PIPE_LEAK':
        #Now calculate total volume of the pipe-formula is:3.14 * length * (diameter / 24) ^ 2
        volume = 3.14 * v_srattrlen * (v_srattrdiameter / 24)**2
        if volume < 1000:
                #If volume is less than 1000 cubic feet, just assign SR to GROUP A
                v_servicegroup = 'GROUP A'
        else:
                #If vol is greater than 1000 cubic ft, assign SR to GROUP B and create worklog
                v_servicegroup = 'GROUP B'
                # Now add the MBO API code to create a new record in the work log for the SR
                worklogset = mbo.getMboSet ('WORKLOG')
                 worklog = worklogset.add()
                 worklog.setValue('clientviewable',1)
                 worklog.setValue('logtype','WORK')
                 worklog.setValue('description','System initiated processing-work assigned to GROUP B')
When the escalation runs, the script executes the following logic:
  1. Checks if the service request has a classification of ’PIPE_LEAK’. Continues execution if a match is found.
  2. Calculates the pipeline volume by using a formula and stores the result in a local variable.
  3. If the volume is less than 1000 cubic feet, assigns the service request to ’GROUP A’.
  4. If the volume is greater than 1000 cubic feet, assigns the service request to ’GROUP B’. Creates a work log to indicate that service request processing started.
The script indicates when the documented MBO APIs must be used. For calculations, you can define input variables to provide the data the script needs. The formula for calculating the pipeline volume is available on many public websites. In this example, the input variables v_srclassif, v_srattrdiameter, and v_srattrlen are used in the script. The input variables are based on the bindings in the SR, TICKETSPECCLASS, and CLASSSTRUCTURE business objects.
Table 1. Variables that are used in the example script
Variable Binding How binding is resolved
v_srclassif CLASSSTRUCTURE.CLASSIFICATIONID The scripting framework traverses the CLASSSTRUCTURE relationship from the SR object to the CLASSSSTRUCTURE object and retrieves the CLASSIFICATIONID value which is a string.
srattrdiameter TICKETSPECCLASS[ASSETATTRID='DIAMETER'].NUMVALUE The scripting framework traverses the TICKETSPECCLASS relationship from the SR object to the TICKETSPECCLASS object and retrieves the value of the diameter attribute. To retrieve one attribute, the binding specifies a filter in square brackets [ASSETATTRID= 'DIAMETER'].
v_srattrlen TICKETSPECCLASS[ASSETATTRID='LENGTH'].NUMVALUE The scripting framework retrieves a single value for the length attribute from the binding and filter.

When the volume of the pipe is calculated, the script checks if the value is greater or less than 1000 cubic feet. Based on the result of the if and else condition in the script, the output variable v_servicegroup is set to service group A or service group B. The script retrieves the value from the v_servicegroup variable and enters the value into the service request.