scripted condition Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 01:54 AM
Hi all,
I would like to create a scripted condition that will trigger the BR when;
-> sc_task state changes to closed complete
and when
-> the related RITM 'item' field is 'catalog item name' (I want this BR to be triggered only for a specific catalog item)
is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 02:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 02:23 AM - edited 08-06-2024 02:24 AM
Hi @dev_K ,
Yes, you can use condition builder in when to run and achieve without any code 'OR'
you can use the 'condition' field and call script include over there. In the script include you can define your conditions such as GlideRecord in the RITM table and check for item field.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 02:55 AM - edited 08-06-2024 02:56 AM
Hi @dev_K,
See the below script and screen shots to achieve this.
Just holler if you need any help.
Tips: Change the 'Item' field to point at the Request Item you want this to apply against in the 'When to run' tab and also update the field you wish to update on line 6 of the 'Advanced' tab view and script.
(function executeRule(current, previous /*null when async*/ ) {
var requestItem = current.getValue("request_item");
if (JSUtil.notNil(requestItem)) {
var parentReqItem = new GlideRecord('sc_req_item')
if (parentReqItem.get(requestItem)) {
parentReqItem.setValue('assigned_to', current.assigned_to); //change the parameters - fields you want to update as required. I've simply demo'ed using assigned_to
parentReqItem.update();
}
}
})(current, previous);
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 03:04 AM
Hi @dev_K ,
You can use the filter condition like below.
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand