We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Get Task Variables In emails Script

Not applicable
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
Giga Patron

Hi @Community Alums ,

refer similar solved threads

https://www.servicenow.com/community/atlanta-snug/catalog-task-variable-information-in-email/m-p/213...

https://www.servicenow.com/community/developer-forum/how-can-i-get-the-variables-in-catalog-task-by-...

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron

@Community Alums 

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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader