Before Delete Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 03:03 AM
Hi All,
I have a requirement that if user click on Delete button on shopping cart page, then it should restrict to delete and print a info message on it.
So for this i have written a Before Delete Business Rule and it is restricting user to delete catalog item. But when i am opening any catalog item page that time that BR is running and it gives an info message before added to the cart.
I did not understand which functionality is affecting.
Can anyone suggest on it.
Below is the BR i have written.
BR is on "sc_cart_item" table.
function onBefore(current, previous) {
gs.log('Inside On After function');
var gr = new GlideRecord('sc_cart_item');
gr.addQuery('cat_item' , 'c89e448b4f034e004430eb1e0210c751');
gr.query();
while(gr.next())
{
current.setAbortAction(true);
gs.addInfoMessage('Should not be Deleted');
gs.log('inside if for deletion message');
}
}
Thanks in Advance.
Regards
Bhushan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 03:25 AM
Hi,
Here is a fix that I have applied to a similar business rule that I have
//When an item is selected in the service catalog it is added and removed from the cart for some reason. We do not want this business rule to run when an item is created and deleted within 1 second
var diffSeconds = gs.dateDiff(current.sys_created_on.getDisplayValue(), gs.nowNoTZ().getDisplayValue(), true);
if (diffSeconds > 1) {
..your code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 03:31 AM
Hello,
Rather than using GlideRecord in script try adding the same in condition part of business rule.
Either in 'when to run' or 'condition part' in Advanced Section.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 06:55 AM
Hi Basha,
Thanks mfor the reply.
I have tried with conditions and when to run. But the issue is same.
Regards
Bhushan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2016 01:59 AM
Anyone have any idea ?