Business rule to calculate a Date from another Date minus XX days

christopher_wat
Kilo Contributor

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);

 

15 REPLIES 15

Chris Waters
Kilo Contributor

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