- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 08:30 AM
Hi everyone,
I’m working on a basic logic for the Account form, where I have a True/False checkbox labeled “Customer.” My goal is to deactivate all contacts related to an account and disable their notifications when this checkbox is unchecked. Although I managed to accomplish this using the flow designer, I believe it should be done with a business rule instead. However, my attempts to create a working business rule have been unsuccessful. Any suggestions?
The Business Rule Details:
Table: customer_contact
When: tried before and after
Regards,
Mo
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:12 AM
Hi @Mohamed Elsayed ,
If you could write the br on "account" table and query your "contact" table to check for account which is set to false, you can achieve this task. You just have to set the workflow and autosysfields to false and set the notification preferences to "none" to achieve this.
Please mark this answer as "Helpful" and "correct" if you feel this answer has helped you in anyway.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 11:27 AM
Hi @Mohamed Elsayed ,
As @Sai_Charan_K already suggested the approach for you to achieve this, I can try to create a sample BR script for you to do it easily with just adjusting the field names/values according to your tables' structure.
BR:
Write an 'After' BR on 'account' table for 'Update' operation, WHEN the 'customer' value changes to 'false'.
In the Script (Under 'Advanced' tab),
var grCust = new GlideRecord('customer_contact');
grCust.addQuery('<account field name>', current.sys_id);
grCust.query();
while(grCust.next()){
grCust.active = false;
grCust.notification = 'disabled';
grCust.update();
}
Please check if this helps you to achieve the solution, or share if you face any challenges.
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 10:12 AM
Hi @Mohamed Elsayed ,
If you could write the br on "account" table and query your "contact" table to check for account which is set to false, you can achieve this task. You just have to set the workflow and autosysfields to false and set the notification preferences to "none" to achieve this.
Please mark this answer as "Helpful" and "correct" if you feel this answer has helped you in anyway.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 11:27 AM
Hi @Mohamed Elsayed ,
As @Sai_Charan_K already suggested the approach for you to achieve this, I can try to create a sample BR script for you to do it easily with just adjusting the field names/values according to your tables' structure.
BR:
Write an 'After' BR on 'account' table for 'Update' operation, WHEN the 'customer' value changes to 'false'.
In the Script (Under 'Advanced' tab),
var grCust = new GlideRecord('customer_contact');
grCust.addQuery('<account field name>', current.sys_id);
grCust.query();
while(grCust.next()){
grCust.active = false;
grCust.notification = 'disabled';
grCust.update();
}
Please check if this helps you to achieve the solution, or share if you face any challenges.
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:25 AM
Thanks Sai_Charan_K & Animesh Das2 for your help, I tested it and it works as expected however, I might stick to the flow as I aim to avoid scripting and keep most of the configuration as low-code as possible. Considering that I am relatively new to the ServiceNow world, it would be appreciated if you check the workflow before I active and move it to production,
Regards,
Mo