Get Task Variables In emails Script

mihirlimje867
Tera Guru
var sc_task = new GlideRecord('sc_task');
sc_task.addQuery('number','TASK0848064');
sc_task.query();
if(sc_task.next()){
    gs.info(sc_task.variables.is_this_a_financial_or_physical_transfer);
    gs.info(sc_task.getRowCount());
}
 
 Output: 
*** Script: undefined
*** Script: 1
 
 
 
Could you please help me to get the value of the variable in the email script or background script?
2 REPLIES 2

Chaitanya ILCR
Kilo Patron

Ankur Bawiskar
Tera Patron
Tera Patron

@mihirlimje867 

your script should also work provided the SC Task -> RITM has that variable

try this as alternative

what's the variable type for is_this_a_financial_or_physical_transfer

var sc_task = new GlideRecord('sc_task');
sc_task.addQuery('number', 'TASK0848064');
sc_task.query();
if (sc_task.next()) {
    var ritmRecord = sc_task.request_item.getRefRecord();
    gs.info(ritmRecord.variables.is_this_a_financial_or_physical_transfer);
    gs.info(sc_task.getRowCount());
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader