Unable to extract the keys from JavaScript object

Document created by naisa13 Employee on Feb 9, 2015Last modified by Douglas Lima on Apr 23, 2015
Version 3Show Document
  • View in full screen mode

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

Outcomes