Copy RITM variables to sc_task worknotes

varma2
Mega Sage

Hi All,

 

I have requirment which need  to copy the all RITM varibles to sc_task worknotes.

 

Could you please help on this to achive the requirment.

 

Thanks all,

Varma

1 ACCEPTED SOLUTION

@varma2 Please try below updated code. It will fix the issues.

 

var ritm = new GlideRecord("sc_req_item");
if(ritm.get(current.request_item.toString())){
var itemOption = new GlideRecord("item_option_new");
itemOption.addQuery("cat_item="+ritm.cat_item.toString());
itemOption.addQuery("nameISNOTEMPTY");
itemOption.orderBy("order");
itemOption.query();

var workNotes = "";
while(itemOption.next()){
workNotes += itemOption.question_text.toString() +" : "+ritm.variables[itemOption.name.toString()].getDisplayValue()+"\n";

}

current.work_notes = workNotes;
}
 
Please mark as correct answer if this solves your issue.

View solution in original post

24 REPLIES 24

@Saurabh Gupta   it working but it copying multiple times in worknotes

 

Thanks.

screenshot please.

Also share the code, need to check if current.work_notes is within loop or outside. it should be outside.

 

 

jaheerhattiwale
Mega Sage

@varma2 Tried and tested solution

Create a before insert business rule on sc_task table. And add below script

 

var ritm = new GlideRecord("sc_req_item");
if(ritm.get(current.request_item.toString())){
var itemOption = new GlideRecord("item_option_new");
itemOption.addQuery("cat_item="+ritm.item.toString());
itemOption.query();

var workNotes = "";
while(itemOption.next()){
workNotes += itemOption.question_text.toString() +" : "+ritm.variables[itemOption.name.toString()]+"\n";

}

current.work_notes = workNotes;
}
 
Please mark as correct answer if this solves your issue.

Hi @jaheerhattiwale 

 

Thanks for reply

i have Implimented your solution But its not working and its not copying RITM varibles to sc_task work note.

Please Suggest.