- 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 06:57 AM
Hi Srini,
In Business Rule you are creating you can apply a condition to it. This means that the Business Rule will only run if the condition matches. So you simply need to add the condition that the flag is not null to achieve the results you desire.
Thanks
If this has been helpful or has answered your question please mark accordingly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:03 AM
When I add a flag 'Flag is not null' then it will run everytime after setting the flag when record is modified.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:13 AM
Is the flag a true/false type field? If so then it will never be Null and will either be true or false (defaulted as false) You should build the condition of the business rule then to be "Flag is false"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2018 07:15 AM
You could write a conditional where current.flag != previous.flag. This way it only runs when that flag is triggered