create business rule with rest api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2017 01:22 PM
Hello,
I've been trying to find out the answer to this in this community and around the web without success so far.
This is what I'm trying to accomplish:
I want to be able to create/get a business rule (the when, what, and advaced script) via the REST api, is this possible?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2017 11:57 AM
You can probably do this using a scripted rest api. Business Rules exist on the 'sys_script' table. You could create a scripted rest api to query the table and return the values you want, or possibly even create a new BR.
Can you provide some details as to your use case?
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 06:26 AM
Hi Tim,
Thanks for replying. Well, what I'm trying to do is to integrate ServiceNow with our system and for that we have a webhook and we'll need ServiceNow to post some of the incidents and some of their data so we can do what we need to do on our side. I created an outbound REST POST (to our webhook) and a Business Rule to use it when some incidents are updated, however my boss would like me to avoid this setup in ServiceNow that a user will have to do 'manually' (creating the business rule) and see if this can be done with some sort of existing api in ServiceNow that way the BR is created by 'clicking' of a button on our side.
I believe I understand what you are suggesting, however it sounds to me like I would end up in the same situation I'm in right now since that 'manual' step would still need to be done in ServiceNow to create and code that rest api to use. right?
I hope this makes more sense now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 07:04 AM
Eric,
Thanks for clarifying. What would be the purpose of the Business Rule? As in, what functionality would a business rule provide to the process? These are usually implemented to run something in the background before or after a record is updated or inserted. You may not need this piece.With a scripted REST API, you can create a custom query to do a GET/POST/PUT on any record you want. You can also configure the script to return whatever response you need. As an example, create an Incident with these field values, and return the Number and SysID in the response so the remote end can have that information for future reference. Essentially, the scripted rest api could act as the 'business rule' to run whatever query you want on the record(s) when you click the 'button' on your remote system.
Can you elaborate on what you mean by this: we'll need ServiceNow to post some of the incidents and some of their data so we can do what we need to do on our side
If I can understand a little better I may be able to post an example of what might work.
Cheers,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 07:38 AM
Tim,
In our system we don't want to 'pull' the information from ServiceNow, instead we want to 'receive' that data from ServiceNow everytime some specific incidents are updated. This is the reason I created a BR to execute *after update*. So when an incident in ServiceNow is updated then it will POST to our webhook. I put some more specific coding in the BR script to filter the incidents (we don't want all incidents to post to our site) and build the body with only the data needed.
In other words ServiceNow should be the one POSTing to our end whenever specific incidents are updated, not us pulling the information every x minutes or by clicking anything. But the issue is that my boss would like to avoid having a user manually setup and create the BR in ServiceNow and instead us creating it via an API call (if exists) in ServiceNow to create BT.