- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 10:08 AM
Can anyone share a business rule script example that prevents record deletion under certain conditions
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 02:20 PM
Hi there @Yashsvi
you can use an br like below
(function executeRule(current, previous /*null when async*/) {
/
if (current.u_status === 'Closed' && current.u_impact === 'High') {
gs.addErrorMessage('Cannot delete record because it is closed with high impact.');
current.setAbortAction(true);
}
})(current, previous);
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 01:06 PM - edited 07-04-2024 01:24 PM
Hi @nafiz435 ,
The business rule would not work because the business rule will run the logic when the records are deleted. You have to add conditions to the delete ACL on the table.
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 01:16 PM - edited 07-04-2024 01:28 PM
Hi @nafiz435,
You could write a before delete business rule that queries associated tables to see if there is are records referencing current and then do a setAbortAction(true) if so.
please check below link:
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 01:22 PM
Hi, you can abort a BR action with a before Delete BR and setAbortAction(); But I would first carefully review the business drives\use case that require this, as I would not normally consider scripted control of record deletion to be best practice and normally records should be retained to preserve audit integrity.
if(current.operation() == 'delete') {
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 02:20 PM
Hi there @Yashsvi
you can use an br like below
(function executeRule(current, previous /*null when async*/) {
/
if (current.u_status === 'Closed' && current.u_impact === 'High') {
gs.addErrorMessage('Cannot delete record because it is closed with high impact.');
current.setAbortAction(true);
}
})(current, previous);
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India