- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:25 AM
Hi all,
I have requirement problem record like when change priority based on that due date will be populated.
If problem reported by INC is P1 -> the due date of the problem record should be +7 working days
if problem is reports by INC is P2 -> the due date of the problem record should be +12 working days
If problem is reported for a P3/P4 -> the due date should be filled in manually.
for this I'm using before business rule.
when to run before insert, update
condition priority is changes
script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:37 AM
hi try this
(function executeRule(current, previous /*null when async*/) {
var datevalue = current.priority;
var days1;
if (datevalue == '1') {
days1 = 7; // P1
} else if (datevalue == '2') {
days1 = 12; // P2
} else if (datevalue == '3' || datevalue == '4' || datevalue == '5') {
current.setValue('due_date', ''); // Clear the due date
}
if (days1) {
var ed = new GlideDateTime();
ed.addDays(days1);
current.due_date = ed;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 01:37 AM
hi try this
(function executeRule(current, previous /*null when async*/) {
var datevalue = current.priority;
var days1;
if (datevalue == '1') {
days1 = 7; // P1
} else if (datevalue == '2') {
days1 = 12; // P2
} else if (datevalue == '3' || datevalue == '4' || datevalue == '5') {
current.setValue('due_date', ''); // Clear the due date
}
if (days1) {
var ed = new GlideDateTime();
ed.addDays(days1);
current.due_date = ed;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 02:16 AM
Hi Harish,
It's working as excepted
Thanks for help.