Business Rule won't run

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 05:33 AM
I need to execute a Business Rule - when a certain catalog item is triggered from a particular Request type, eg., if the short description of the Request starts with "IT onboarding for".
I have setup a business rule to run on Insert of the particular catalog item - and in the business rule itself wrote the below code to check the request's short description:
var check = new GlideRecord("sc_task");
check.addEncodedQuery("cat_item=717ab6fd13b7f6042b3fXXXXXXXXX^request.short_descriptionSTARTSWITHIT onboarding request for");
check.addQuery("sys_id", current.sys_id);
check.query();
if (check.next()) {
//Confirmed that its linked to "IT Onboarding request"
//trigger the payload
}
But the Business Rule, simply won't run, if I enable the "Update" flag and test by updating the Task - it works, just not on Insert. Please advise!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 07:26 AM
Hi @Community Alums ,
Still I don't have an answer to your question, but just let me clarify.
> if I enable the "Update" flag and test by updating the Task - it works, just not on Insert.
So, do you set "sc_task" table for your triggering table? And also do you set "before" or "After" in When field?
I am just afraid that the new record is not yet inserted when your Business Rule runs,,,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 04:10 AM
Hi @aizawaken !
To answer your questions:
> Yes, it works when I enable "Update" (on update) in the Business Rule, just not on Insert.
> The table is "sc_task", and its an "After" Business Rule, so After Insert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 08:16 AM
Hi @Community Alums ,
I just tried same conditions as you mentioned, and it seems that it is working as expected.
Then, I could get the message as below.
Still I have not find out the root cause, but in my environment, your script runs fine.
Are there any difference between yours and mine?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 03:10 AM
Hi @aizawaken!
The script is exactly the same - of course, within the IF loop - I'm triggering a Rest Outbound. This is my headache, logically it should run fine - but doesn't. Only difference I can think of - is that the REQ is created via humongous user provisioning script via a parent HRCASE ticket.