Copying variables from an RITM into a change task?

bradschamerloh
Kilo Expert

I'm having problems getting a couple variables from an RITM copied into a change task.

I've built a workflow that creates a task after someone requests something.   So the person that's responsible for working on the task doesn't have to go into the RITM, I simply just want to copy the variables of the RITM into the change task.

RITM Variables:

find_real_file.png

Want to copy these two lines into the change task

find_real_file.png

1 ACCEPTED SOLUTION

Brad,



Try this


var var_list='';


var set = new GlideappVariablePoolQuestionSet();


set.setRequestID(current.getValue('sys_id'));


set.load();


var vs = set.getFlatQuestions();


for (var i=0; i < vs.size(); i++) {


      if((vs.get(i).getName()=='put in your variable Name here') || (vs.get(i).getName()=='put in your variable Name here')) {            


          var_list+=vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n";


      }


}  


task.description=var_list;


task.short_description=var_list;



This should work a expected now. Don't forget mark my responses as helpful and one of them as correct.



Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

14 REPLIES 14

Abhinay Erra
Giga Sage

Brad,



Assuming your workflow is on sc_req_item table and creating a task using create task workflow activity. Copy the following script into the create task workflow activity and this will copy the 2 variables into description field on the task


script:


var set = new GlideappVariablePoolQuestionSet();


set.setRequestID(current.getValue('sys_id'));


set.load();  


var vs = set.getFlatQuestions();  


for (var i=0; i < vs.size(); i++) {  


      if((vs.get(i).getLabel()=='put in your variable label here') || (vs.get(i).getLabel()=='put in your variable label here')) {                


            task.description=vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n";    


      }  


}      



Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


bradschamerloh
Kilo Expert

Added in the script to the activity:



find_real_file.png



Still not getting any results in the description fields



find_real_file.png


Brad,



I see that you have put in the variable names.(short_desc..) You need to put in the labels of your variable not the name.



Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


bradschamerloh
Kilo Expert

I apologize for not following, but I don't see any "label" fields within the variables



find_real_file.png