Business rule to calculate a Date from another Date minus XX days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2018 03:04 AM
Hi,
I am trying to create a business rule which will take one Date value from a field, then based on selection of choice another field return a new date in other field, its to work out a review date on a contract based on end date, initially one choiuce only, but there would be two choices
ends - the date the contract due to end
u_ck_renewal_or_termination_period - the selection used to determine the new date
renewal_end_date - where I want the date calculated entered
I have tried the following script, which doesn't seem to work, using Istanbul, no conditions, before, on uodate, insert, any suggetsions on my error, ommsision or alternative methods would be apprecaited
Many thanks
Table: ast_contract
(function executeRule(current, previous /*null when async*/) {
var gdt = current.ends.getGlideObject();
if (current.u_ck_renewal_or_termination_period =='3 Months'){
current.renewal_end_date=gdt.subtractDays(90);
}
})(current, previous);
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2018 04:11 AM
Thanks Archana, just looks at the Ends Dictionary, Calculated is not ticked so no script there, also dependent field are not listed
This is the full script being used, Before, Insert or Update
Filter Condition on Renewal or Termination period Changes
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("You updated the expiry date");
var gdt = current.ends.getGlideObject();
if (current.u_ck_renewal_or_termination_period =='3 months'){
gdt.addDaysLocalTime(-90);
current.renewal_date=gdt;
}
})(current, previous);
Thanks
Chris