businesss rule to check user is vip
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2022 03:48 AM
i need to write an after business rule to check whether the caller of the incident is VIP or not and if yes it should populate the caller in the description.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2022 03:53 AM
Try the following in the before Business rule
Filter condition
caller_id.vip=true
Code
current.setValue('description', current.getDisplayValue('caller_id'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2022 03:58 AM
Hi @hemasree kanduk ,
You have to write a Before insert/update business rule instead of After.
Try this sample scripts with condition as Caller ISNOTEMPTY.
(function executeRule(current, previous /*null when async*/) {
if(current.caller_id.vip == true){
// add your scripts here
current.short_description = current.caller_id.getDisplayValue() + " - " + previous.short_description;
}
})(current, previous);
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2022 04:47 AM - edited ‎10-26-2022 04:48 AM
Hi @hemasree kanduk ,
Could you please elaborate your use case. As you mentioned in your problem statement "You need to write an after business rule". This will not make sense as after BR executes after your data is saved in database. Now if you make any change in description after saving data in table, it will be useless untill you do not save it again.
1. If your use case is "Whatever end user writes in short description field, on submitssion of form if calller is VIP then caller name should appear before description in that case you can use below script in a Before insert and update BR :
For condition to check if caller is VIP always prefer to use condition builder wherever possible. Here you will have to dot walk to get VIP ( Caller.VIP)
current.description = current.caller_id.getDisplayValue() + " : " + current.getValue("short_description");
2. If your use case is "If calller of incident is VIP then caller name should appear in description" in that case you can use below script in a Before insert and update BR
current.description = current.caller_id.getDisplayValue();
If your use case is anything else, please let us know so that we can help better
I Hope this helps.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh