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