i need one example of before business rule with scenario?

ram2497
Tera Contributor

i need one example of before business rule with scenario?

1 ACCEPTED SOLUTION

Shashikant Yada
Tera Guru

 

Compare start and end date using BR, before inserting record

(function executeRule(current, previous /*null when async*/) {
//if(current.u_project_end_date != ''){
var start_date=current.u_project_start_date.getGlideObject().getNumericValue();
var end_date = current.u_project_end_date.getGlideObject().getNumericValue();
if(start_date > end_date)
{
gs.addInfoMessage("Start date cannot be greater than end date");
current.setAbortAction(true);
}
//}
})(current, previous);

View solution in original post

2 REPLIES 2

Shashikant Yada
Tera Guru

 

Compare start and end date using BR, before inserting record

(function executeRule(current, previous /*null when async*/) {
//if(current.u_project_end_date != ''){
var start_date=current.u_project_start_date.getGlideObject().getNumericValue();
var end_date = current.u_project_end_date.getGlideObject().getNumericValue();
if(start_date > end_date)
{
gs.addInfoMessage("Start date cannot be greater than end date");
current.setAbortAction(true);
}
//}
})(current, previous);

Jaspal Singh
Mega Patron
Mega Patron

Hi Ram,

 

Before business rule runs before record is inserted/updated in Database. 

As Shashikant suggested Date validation rule before insertion. If this is done after insert it makes no sense as it would accept dates that actually it should now. So, Before is used in order to validate & then insert.

Refer link that gives detailed explanation for all Business Rule types.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.