- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 06:48 AM
I have a requirement to run the business rule logic only once based on a flag. Initially flag will be null and once it its set, business rule should run and when user tried to modify the record again, business rule should not run.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:18 AM
As I am not sure of your exact requirement below are the possibilities:
1. Run the BR only on Insert if that needs to be run only on new records.
2. If BR needs to be run only if the flag changes from null, then you can choose the filter "changes from" condition.
3. If both of them doesn't fulfill your requirement, you can make the BR inactive after first run. Below is the script:
// perform your actions first
//e.g.
gs.addInfoMessage("This message will only show once for this record.");
//make this BR inactive
var gr = new GlideRecord('sys_script');
gr.get('sys_id of the Business Rule');
gr.active = false;
gr.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:09 AM
You can write business rule and in the script
You can write like
if(flag=="")
{
write your script
}
else
{
current.setActionAbort(true);
}
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:13 AM
This would abort the DB action every time after the flag is set to true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:38 AM
It would work I guess, only else part needs to be removed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:18 AM
As I am not sure of your exact requirement below are the possibilities:
1. Run the BR only on Insert if that needs to be run only on new records.
2. If BR needs to be run only if the flag changes from null, then you can choose the filter "changes from" condition.
3. If both of them doesn't fulfill your requirement, you can make the BR inactive after first run. Below is the script:
// perform your actions first
//e.g.
gs.addInfoMessage("This message will only show once for this record.");
//make this BR inactive
var gr = new GlideRecord('sys_script');
gr.get('sys_id of the Business Rule');
gr.active = false;
gr.update();