- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:50 PM
Hi ALL,
i want to update caller's email and department name in short description when ever a incident record created on snow.
can any one help me with that?
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 09:36 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:56 PM
Hi @Priyansh_98 ,
Write before insert BR and use below code.
(function executeRule(current, previous /*null when async*/) {
// Ensure there's a Caller
if (current.caller_id) {
// Get the Caller record
var caller = new GlideRecord('sys_user');
if (caller.get(current.caller_id)) {
var email = caller.email;
var departmentName = caller.department.name;
current.short_description = 'Caller: ' +email+' Department: '+ departmentName;
}
}
})(current, previous);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 11:00 PM
you can use before insert BR on incident table
Condition: Caller ID [IS NOT EMPTY]
Script:
(function executeRule(current, previous /*null when async*/) {
current.short_description = 'Email: ' + current.caller_id.email + ', Department: ' + current.caller_id.department.name;
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 11:56 PM
Hi @Ankur Bawiskar ,
Thanks for your response...!!
can i do it using client script also?
i tried getreference method on client script, but i am not able to get department name. i am getting undefined..!!!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var cl = g_form.getReference('caller_id');
// alert(cl);
// alert(cl.email);
alert(g_form.getDisplayValue(cl.department));
var email = cl.email;
var dept = cl.department.name;
var desc = g_form.getValue('short_description');
var new_desc = desc + '_' + email + '_' + dept;
g_form.setValue('short_description', new_desc);
function callback() {
}
}
output below..
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 12:27 AM
you will have to use GlideAjax for this as you cannot dot walk 1 more level in client script.
Why not use Business rule?
It will avoid creation of script include and client script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader