IT Process Automation

Unable to extract the keys from JavaScript object 

Feb 09, 2015 09:18 AM

I'm using PAM 4.2.2 version.

 

Below is the javascript i'm execution using Run Java Script Operator

_____________________________________________________________________

var obj ={   "key1": "value1",  "key2": "value2",  "key3": "value3","key4": "value4" }

Process.objType = typeof obj

Process.keys1 = []

for (var key in obj)

{

  if (obj.hasOwnProperty(key))

  Process.keys1.push(key)

}

____________________________________________________________________

for the above code array Process.keys1 is getting appended with keys 'key1','keys2' ... when created the object manually.

 

In other case, the same object is being created by SRF,

 

With same code the keys are not getting populated to keys1 array.

 

I've attached the StartReqestForm and Process.

Can any one suggest what should i do to get the keys from the object.??

 

This document was generated from the following discussion: Unable to extract the keys from JavaScript object

 

*************************************************************************************************

Adding the solution from the discussion: DouglasLima

*************************************************************************************************

 

Hi naisa13,

Looking your code and testing a little, I change the code and I did something that could help you:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Process.gcsEnv = ['Dev','QA','Training','Test'];

Process.hypEnv = ['Dev','QA'];

 

//Process.gcs

var obj = Process.gcs;

 

Process.objType = typeof obj;

Process.keys1 = [];

 

Process.vlMap = getValueMapFields(obj);

 

for(i = 0; i< Process.vlMap.length; i++)

{

  if(obj[Process.vlMap[i]])

  {

  Process.keys1.push(Process.vlMap[i]);

  }

}

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

For sure, this code is only one example and I hope that help you a little.


You will find the system functions in this manual:

Content Designer Reference Release 04.2.00

Search for CA Process Automation System Functions.

 

Best Regards,

Douglas Lima

Statistics
0 Favorited
1 Views
2 Files
0 Shares
0 Downloads
Attachment(s)
zip file
Start Request Form.xml.zip   2 KB   1 version
Uploaded - May 29, 2019
zip file
PatchServiceStop.xml.zip   4 KB   1 version
Uploaded - May 29, 2019

Related Entries and Links

No Related Resource entered.