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

Sorry for the confusion, I meant question. But, I see your question is too long. So I tweaked the code a little bit to use name instead of questions



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')) {              


            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

Ok, I think we're getting somewhere.   I added in some code in hopes of populating both the short description & description fields, but I messed up somewhere.



Here is what I have as of right now



find_real_file.png



Using:



find_real_file.png


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


I have a similar issue i am trying to get my variables to write to the TASK description field.   I have tried your script in the Catalog task workflow item but nothing is writting.   Please advise, here are the variables (questions) and the current script in place: (note I did not write the below script, I just need to add additional information for our new variables).



find_real_file.png



find_real_file.png


Did you use GlideappVariablePoolQuestionSet ?