- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 05:54 PM - edited 01-22-2025 02:18 PM
Trying to use this API: https://www.servicenow.com/docs/bundle/xanadu-application-development/page/build/servicenow-sdk/refe...
I can create a business rule no problem using this json body:
```
{
"name": "XXXXXX",
"table": "incident",
"when": "after",
"action": ["insert", "update", "delete"],
"active": true,
"condition": "true",
"script": "XXXXXXXX"
}
```
but the table and actions are not set.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 02:17 PM
The API documentation is wrong, the correct way to set the table is to use the "collection" field and the correct way to set the actions are to append a prefix of "action_" and it is not an array of actions, it's a string!
so
{
"name": "XXXXXX",
"collection": "incident",
"when": "after",
"action_insert": "true",
"action_update": "true",
"action_query": "true",
"action_delete": "true",
"active": true,
"condition": "true",
"script": "XXXXX"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 08:10 PM
but why to create BR using API?
Not a good practice
I don't think it's a valid business requirement to create BR via API
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 08:17 PM
There is a valid reason and there is an API with clear documentation so why not!
The question is why is the API not working as documented. Is it a user error somewhere or an API bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 08:20 PM
Why is it not a good practice? Either case my use case requires it. I just need to know why it's not working, and what the issue is here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 02:17 PM
The API documentation is wrong, the correct way to set the table is to use the "collection" field and the correct way to set the actions are to append a prefix of "action_" and it is not an array of actions, it's a string!
so
{
"name": "XXXXXX",
"collection": "incident",
"when": "after",
"action_insert": "true",
"action_update": "true",
"action_query": "true",
"action_delete": "true",
"active": true,
"condition": "true",
"script": "XXXXX"
}