I want a script for workflow conditions.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 11:23 PM
I am looking for a script to meet mu condition.
My condition is to :
- If Opened by is the same as the Manager then it should trigger task. If
- If Manager is inactive --- then it should trigger other task.
Labels:
- Labels:
-
Data Foundations
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 01:06 AM
Hello @Taaha M ,
Please refer below code for a example and update it as per your req:
(function checkConditions(current) {
var openedBy = current.opened_by;
var manager = openedBy.manager;
if (!manager) {
// No manager assigned, return false
return false;
}
// Check if 'Opened by' is the same as 'Manager'
if (openedBy == manager) {
// Trigger the first task
workflow.scratchpad.triggerTask = 'task1';
return true;
}
// Check if the manager is inactive
var grManager = new GlideRecord('sys_user');
if (grManager.get(manager) && grManager.active == false) {
// Trigger the second task
workflow.scratchpad.triggerTask = 'task2';
return true;
}
return false;
})(current);
Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!
Dnyaneshwaree Satpute
Tera Guru
Thank you!!
Dnyaneshwaree Satpute
Tera Guru