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.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

24 REPLIES 24

@varma2 It worked?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Hi @jaheerhattiwale 

 

Yes it copying  the variable but it not occurate what i mean 

 

1. refernce variable values showing as SYS_id

2. varibles  not showing by ORDER

3.choices other varible type are showing zigzag,

 

Below are the example of cpoied vRIABLES.

Primary Business Line :
Used For : undefined
Approval group : 3144b2f4db795950b3f04641ba961993
Role :
Request Type : Grant access
Managed By Group : 0a757e83db1ac5d02d546ac2ca96198d
Other Buisness Lines :
: undefined
Requested For Location : Bengaluru - IND09
Primary Sales Area :
Specify any further remarks or details for this request : j
SPO User profile :
Support Group :
Requested For Title :
: undefined
: undefined
Other Sales Areas :
API : undefined
RAC : undefined
HOC : undefined
For OsiSoft PI, the application names represent the different roles.
Click on this <link> to see more detailed information about these roles. :
INC : undefined
Start date :
Justification : ALL-NU-G-MFA_E5_PowerBI
CAN : undefined
FCE : undefined
Row Level Security information : ter
Start : undefined
: undefined

 

Thanks

@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.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@varma2 Have you tried this?

 

If not please try this. This should fix your issue.

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Rahimunnisa Sha
Kilo Guru

@varma2 

In your case if the Catalog task created from the workflow add the below script in the Catalog Task activity in workflow.

task.work_notes = "Variable1="+current.variables.variable1+'\n'+"Variable2="+current.variables.variable2+'\n'+"Variable3="+current.variables.variable3+..............

add the backend values of variables..