IT Process Automation

  • 1.  Assign Process Variables from FormVM array

    Posted Jan 18, 2017 12:28 PM

    Hi Community,

     

    I'm working on a Service Catalog approval process that takes the Approvers from the the form via $form_data_sd_row$ parameter.  I'm having trouble assigning the returned data to process variables.  Initially, I was trying to use $form_data_sd$, however the data was not being passed to PAM and the Process.scFormData variable was NIL.

     

    I've highlighted a value from the FormVM array that I'm trying to assign to a Process Variable.  I've tried several forms of the following for loop, nothing seems to be working.

     

    Any advice is appreciated.  Thanks!

     

    Process.FormVM = convertJson(Process.scFormData);

    for (m=0; m<Process.FormVM.length;m++){
      if(Process.FormVM[m].name.match("txtf_approver1")){
      Process.approver1 =Process.FormVM[m].value;
    }
    }



  • 2.  Re: Assign Process Variables from FormVM array

    Posted Jan 18, 2017 12:51 PM

    Just going off what you are showing here, you are missing the '11815' part of the parameter name. Your array references should read 'Process.FormVM.11815.length' and 'Process.FormVM.11815[m].name' and 'Process.FormVM.11815[m].value'



  • 3.  Re: Assign Process Variables from FormVM array

    Posted Jan 18, 2017 01:22 PM

    Hi Benjamin,

     

    Thank you for the response, I've tried formatting the for loop similar to that.  I think my problem is I'm not passing the 11815 value correctly.  I'm not sure why, but this value is always the Service Catalog RequestItemID + 1.  To accommodate this, I'm creating a variable named jsonObj and setting it to the expected value.  However, I'm not sure it's being passed into the for loop.

     

    Process.FormVM.jsonObj.length returns the following error.

    var jsonObj = Process.RequestItemID+1;
    Process.jsonTest = jsonObj;


    Process.FormVM = convertJson(Process.scFormData);

    Process.FormVMLength = Process.FormVM.jsonObj.length;

    for (m=0; m<Process.FormVM.jsonObj.length;m++){
      if(Process.FormVM.jsonObj[m].name.match("txtf_approver1")){
         Process.approver1 = Process.FormVM.jsonObj[m].value;
      }
    }


  • 4.  Re: Assign Process Variables from FormVM array

    Posted Jan 18, 2017 03:26 PM

    Grant,


    Try Process.FormLength = Process.FormVM[jsonObj].length. Since you need the value within jsonObj, you have to use the brackets so that the interpreter will evaluate the string.



  • 5.  Re: Assign Process Variables from FormVM array

    Posted Jan 18, 2017 03:49 PM

    I get a different error with that syntax.  Do I need to define a valuemap for this array on the dataset?

     

     -- msg.valuemap.no.indexed.access (#18)



  • 6.  Re: Assign Process Variables from FormVM array

    Posted Jan 18, 2017 04:07 PM

    What is the value of jsonObj?



  • 7.  Re: Assign Process Variables from FormVM array
    Best Answer

    Posted Jan 18, 2017 06:21 PM

    Hi Benjamin,

     

    The value of jsonObj was equal to the RequestItemID passed from Service catalog.  I managed to get this to work another way by using the getFormRateItemValues operator.  I was then able to set the process variables using the for loop below.  Thank you your help, I think we'll stick to using this operator as it makes it a bit easier.

     

    for (m=0; m<Process.arrayFormResults.length;m++){
      if(Process.arrayFormResults[m].strKey.match("txtf_approver1")){
         Process.approver1 = Process.arrayFormResults[m].strValue;
      }
      if(Process.arrayFormResults[m].strKey.match("txtf_approver2")){
         Process.approver2 = Process.arrayFormResults[m].strValue;
      }
      if(Process.arrayFormResults[m].strKey.match("txtf_approver3")){
         Process.approver3 = Process.arrayFormResults[m].strValue;
      }
      if(Process.arrayFormResults[m].strKey.match("txtf_approver4")){
         Process.approver4 = Process.arrayFormResults[m].strValue;
      }
      if(Process.arrayFormResults[m].strKey.match("txtf_approver5")){
         Process.approver5 = Process.arrayFormResults[m].strValue;
      }
      if(Process.arrayFormResults[m].strKey.match("txtf_escalation")){
         Process.escalation = Process.arrayFormResults[m].strValue;
      }
    }