Get Task Variables In emails Script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:16 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:20 AM
Hi @mihirlimje867 ,
refer similar solved threads
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 05:27 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader