Using a Javascript to store data returned from a Service Desk operator into an CA Process Automation dataset

book

Article ID: 49419

calendar_today

Updated On:

Products

CA Workload Automation AE - Business Agents (AutoSys) CA Workload Automation AE - Scheduler (AutoSys) CA Workload Automation Agent CA Process Automation Base

Issue/Introduction

Description:

These instructions walk you through adding javascript code to your CA Process Automation environment that can be referenced in an CA Process Automation process to pull data returned by SD operators into an CA Process Automation dataset for easy reference.

Solution:

Create a file called servicedeskresults.js and add the following text into this file:

function GenFieldName(t_str, t_num) {
   return t_str.substr(-1 * t_num).replace(".", "_")
}
 
function ProcessBaseSelectResults() {
   if (Process[OpName].Result != 1) {
       return
   }
 
   t_responseObject = Process[OpName].SelectDataResponse.UDSObject
   if (typeof(t_responseObject) == "undefined") {
       return
   }
   
   // Set up the field names using the first object in the response
   fieldNames = new Array()
   for (t_index = 0; t_index < t_responseObject[0].Attributes[0].Attribute.length; t_index++) {
       fieldNames[t_index] = GenFieldName(t_responseObject[0].Attributes[0].Attribute[t_index].AttrName[0].text_, 32)
   }        
   
   t_resultObjects = new Array()
   for (t_objIndex = 0; t_objIndex < t_responseObject.length; t_objIndex++) {
       t_vmap = newValueMap()
       for (t_attrIndex = 0; t_attrIndex < t_responseObject[t_objIndex].Attributes[0].Attribute.length; t_attrIndex++) {
           t_vmap[fieldNames[t_attrIndex]] = t_responseObject[t_objIndex].Attributes[0].Attribute[t_attrIndex].AttrValue[0].text_
       }
       t_resultObjects.push(t_vmap)
   }        
   Process[OpName].resultObjects = t_resultObjects
}

To add this file to CA Process Automation, log into PAM and on the initial screen (the management console) select the Manage Version tab on the bottom left. Then with the "CA Process Automation User Resources" folder highlighted, select the New button in the upper right corner. It is very important that the User Resources folder is selected or this will not work. Give it the resource name servicedeskresults and a description and then browse in the Resource File field for the servicedeskresults.js file. You can leave the rest of the fields blank.

<Please see attached file for image>

Figure 1

Then click Submit at the bottom. Close all browsers and log back into CA Process Automation.

Once this has been successfully imported you can use this java script in your processes. Go into the CA Process Automation client and create a process using the Base Select Service Desk Element Operator.

<Please see attached file for image>

Figure 2

Fill in the parameters for the Base Select Service Desk Element operator similar to the screen print below:

<Please see attached file for image>

Figure 3

On the Post Execution code screen of the Base Select Service Desk Element in your process, enter the following:

include("servicedeskresults.js");
ProcessBaseSelectResults();

<Please see attached file for image>

Figure 4

Now when you run your process, the results in the SoapResponseBody will be added to the dataset in an easy to find location. You can find the data in the dataset dropdown under the operator name (by default is it Base_Select_Service_Desk_Eleme_1) and in the System folder under resultObjects is the valuemap created by the javascript to hold the data returned from Service Desk.

<Please see attached file for image>

Figure 5

<Please see attached file for image>

Figure 6

The operator that this works with is the Base Select Service Desk Operator. But if you are using other operators you can modify the javascript to correct for that. The javascript has SelectDataResponse hard coded which is the Base Select Service Desk Element operator response field name, but this is different for the other operators so you will just need to modify that in the javascript or upload a new java script with a different name to use both. For example the Select Request Operator uses SelectRequestResponse. You can see the corresponding response field name for the operator you are using on the Operation Results palette off of the Logs tab (shown in the screen shot below) when you run the process containing this operator.

<Please see attached file for image>

Figure 7

Environment

Release:
Component: ITPAM

Attachments

1558712308091000049419_sktwi1f5rjvs16slc.gif get_app
1558712306277000049419_sktwi1f5rjvs16slb.gif get_app
1558712304389000049419_sktwi1f5rjvs16sla.gif get_app
1558712302311000049419_sktwi1f5rjvs16sl9.gif get_app
1558712300427000049419_sktwi1f5rjvs16sl8.gif get_app
1558712298540000049419_sktwi1f5rjvs16sl7.gif get_app
1558712296294000049419_sktwi1f5rjvs16sl6.gif get_app