IT Process Automation

  • 1.  Unable to extract the keys from JavaScript object

    Posted Feb 09, 2015 09:10 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.??

    Attachment(s)



  • 2.  Re: Unable to extract the keys from JavaScript object
    Best Answer

    Posted Feb 25, 2015 04:34 PM

    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.


    Best regards,

    Douglas Lima



  • 3.  Re: Unable to extract the keys from JavaScript object

    Posted Feb 26, 2015 01:12 PM

    Thank you Douglas, Indeed it had helped me.

    How can I get more information about the inbuilt functions like getValueMapFields in PAM?



  • 4.  Re: Unable to extract the keys from JavaScript object

    Posted Feb 26, 2015 01:41 PM

     

    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