I am using this script in workflow , but i'm getting an error please check it?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 02:33 AM
Script :
function ifScript() {
try {
var ritmGR = new GlideRecord("sc_req_item");
if (!ritmGR.get(current.sys_id)) {
gs.error("Unable to get sc_req_item record with sys_id: " + current.sys_id);
return 'error';
}
var user = ritmGR.variables.requested_for;
// Check if the user has the 'itil' role
var gr = new GlideRecord('sys_user');
if (!gr.get(user)) {
gs.error("Unable to get sys_user record for user: " + user);
return 'error';
}
if (gr.hasRole('itil')) {
return 'yes';
} else {
return 'no';
}
} catch (e) {
gs.error("An error occurred: " + e);
return 'error';
}
}
// Call the function and store the result in the 'answer' variable
var answer = ifScript();
// Log the result to the script log
gs.info('Result: ' + answer);
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 05:11 AM
Hello @1dusjhyahnt ,
Can please share the more details or your business requirement? Which type of error you are facing?
Regards,
Vaishnavi Shinde
