Business Rules and Scripted REST API

lobando
Kilo Explorer

I have an scripted REST API and one of the endpoints does an insert to a table after doing some calculations. This table have some business rules doing some validations.

My question is, is there a way to get the error messages from the business rule all the way to the REST endpoint to be able to send it back to the caller ?

Thanks

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

How are they currently showing error messages for those validations? I would think you'll need to edit those rules to return their error messages in a different way.


Right now I'm just doing a regular gs.addErrorMessage that will just show


it on the UI.


I'm looking for another way, what do you have in mind?



Thanks for the help.



Luis



On Mon, Feb 29, 2016 at 2:24 PM, b-rad <community-no-reply@servicenow.com>


Hello,


I need to create a Webservice API where input is: Sys ID of any record and output is: all *related* active records to that sys id. The relationships between the tables is maintained in Relationships under system definition.


Could you please guide me how to implement this? Sample code would be great.


Input: Sys ID of the record
Output: All *RELATED* active records from *VARIOUS* tables (in the following JSON format):
{
"result": [
{
"Sys ID": "5520267",
"CI Name": "Record 1",
"Table Name": "u_table_a"
},
{
"Sys ID": "5520367",
"CI Name": "Record 2",
"Table Name": "u_table_a"
},
{
"Sys ID": "8331210",
"CI Name": "Record 1",
"Table Name": "u_table_b"
},
{
"Sys ID": "8321210",
"CI Name": "Record 2",
"Table Name": "u_table_b"
},
{
"Sys ID": "3042006",
"CI Name": "Record 3",
"Table Name": "u_table_b"
},
{
"Sys ID": "4509847",
"CI Name": "Record 1",
"Table Name": ""u_table_c"
}
{
"Sys ID": "4509247",
"CI Name": "Record 2",
"Table Name": ""u_table_c"
}
]
}