IT Process Automation

Expand all | Collapse all

Pass attribute from Select_Object to Get_Object

  • 1.  Pass attribute from Select_Object to Get_Object

    Posted 09-05-2014 02:10 PM

    We have a process set up to select an attribute from a Change order and then pass that to a Get_Object operator in order to retrieve an attribute from Novell eDirectory.  The Select_Object retrieves affected_contact.billing_code.name from the change order and the Get_Object uses that attribute to pull the Authorized individual coordinator for that specific CostCenter.   

     

    If I manually enter the cost center into the retrieve filter of the Get_Object operator, I can see the Authorized individual for that cost center.  So I know it can communicate with the eDirectory.

                "(&(objectclass=CostCenter)(cn=20-9950)"

     

    When I attempt to use the retrieve filter via Select_Object_1 dataset nothing is being returned.

      "(&(objectclass=CostCenter)(cn=Process.Select_Object_1.SelectDataResponse.UDSObject[0].Attributes[0].Attribute[0].AttrValue[0].text_))"

     

    Have also tried using the applyXPath method.  The process completes but nothing shows under RetrieveObjects. Please assist.



  • 2.  Re: Pass attribute from Select_Object to Get_Object

    Posted 09-11-2014 07:07 AM

    Hi Matt,

     

    I had the same problem to process the results of that kind of object. Spending lot of time to extract specific parameters, etc, etc... To solve that I'll share my solution for that explaining with an example.

     

    This is what I do when I use select_object operators (using an example for people who is new in CA PAM):

     

    1) Create a folder to store all your automatisms called "Core". You'll put all you objects inside the folder.

    2) Create a DataSet object called "globalDS" inside the root folder (Core).

    3) Edit the DataSet object and create a variable called "JSCommonFunctions" [type:String]

    4) Paste this code I created for my selects on "JSCommonFunctions" value field, save it and check it Out ("Check Out" button):


    // Common function to return an array of valueMap objects with the requested fields in the selection available.

    function SDMSelectPostExec() {

      var resultMap = [];

      var resultUDSObject = Process[OpName].SelectDataResponse.UDSObject;

     

      // If selection return something will process it and extract all parameters with their values

      if (Process[OpName].SelectDataResponse.UDSObject.length == 0) {

      resultMap = null;

      }

      else {

      for (var i = 0; i < Process[OpName].SelectDataResponse.UDSObject.length; i++ )

      {

       var resultItem = resultUDSObject[i].Attributes[0].Attribute;

      

       var item = newValueMap();

       for (var j = 0; j < resultItem.length; j++)

       {

      item[resultItem[j].AttrName[0].text_] =  resultItem[j].AttrValue[0].text_;

       }

       resultMap[resultMap.length] = item;

      }

      }

     

      return resultMap;

    }

     

    5) Now edit post execution code of your Select Object object and paste this code:

     

    // Load the dataset called globalDS stored con "/Core/" path in the globalDS variable of the process.

    // NOTE: "Process.globalDS" it's created now on runtime. You don't need to delare it in any place before this instruction

    // NOTE: You can execute this line ONCE in the pre-execution code of the first at the beginning of the process

    Process.globalDS = Datasets["/Core/globalDS"];

     

    //Load the code we stored

    load(Process.GblDSVals.JSCommonFunctions);

     

    var result = SDMSelectPostExec(); // Execute function to get an array of valuemaps. A valuemap per result of de select.

     

    Process.result = result;  // NOTE If you expect just one element you can use Process.result = result[0];

     

    6) voila!! You have an array filled with associative arrays (Valuemap) with all the parameters you requested. You only have to take a look con your select field list of the Select object. I'll explain better:

    Imagine you put some fields to be retrived on your Selec_object object. For example: id, name, cost_center and status.

     

    After that post-execution code you can access to Process.result array when ever you want until the end of the process.

     

    Imagine the select returned 2 items:

     

    a) id: 123

      name: Peter

      cost_center: Madrid

      status: active

     

    b) id: 456

      name: Sara

      cost_center: Barcelona

      status: active

     

    How to access the value? Easy! after you put "Process.result = result;" line:

     

    var item = Process.result[0]; //NOTE: if you thing you can get undefined number of results you can use a for loop

     

    // now the only thing you have to do is

    // item.id

    // item.name

    // item.cost_center

    // item.status

     

    If you add a new field like "surname" you don't have to worry about. You don't have to edit your post-execution code.

     

     

    Hope it helped and solved your question



  • 3.  Re: Pass attribute from Select_Object to Get_Object

    Posted 09-23-2014 01:31 PM

    Thank you xlluch.

     

    It looks like the original issue was my retrieve filter was missing the plus signs around the variable that I had created in the Select_Object post execution code.  The retrieve filter works with the below information:

    "(&(objectclass=fhCostCenter)(cn="+ Process.CustomerCC + "))"

     

    Now that that is working I will play around with storing all the information returned in the array you suggested.