How to fetch Incident modification activities from Service-now API

anuruddha banda
Kilo Contributor

I was able to get created Incidents from the Service-now table API. I want to know is there any endpoint available to fetch each incidents modifications activities after those modified by someone. 

1 ACCEPTED SOLUTION

Instead of using endPoint function you should create the REST MESSAGE and call In your script

var request = new sn_ws.RESTMessageV2('YourRestMsgName','Post');

Regards,

Suresh.

Regards,
Suresh.

View solution in original post

11 REPLIES 11

Sure i will check it, Thanks 🙂 

As you mention REST Message and tested it. Also the script for the REST message. I include that script in business rules. I tried this with another service-now instance. 

Work flow for the Business Rule script

When i create or update an incident of Instance-A, this business rule will run and send a POST request to instance-B to create a new incident same as which updated or created in instance-A.

 

01) By setting up my server endpoint to the request.setEndpoint() will i able to get modifications info.?

ex:

request.setEndpoint('https://mydomain/api/modifications');

 

Script 

(function executeRule(current, previous /*null when async*/ ) {
    if (current.sys_updated_on.toString() != previous.sys_updated_on.toString()) {
        var request = new sn_ws.RESTMessageV2();
        request.setEndpoint('https://<instance>.service-now.com/api/now/table/incident');
        request.setHttpMethod('POST');

        var user = 'admin';
        var password = '<password>';
        var data = {
            short_description: current.short_description.toString(),
            caller_id: current.caller_id.email.toString(),
            state: current.state.toString()
        };

        request.setBasicAuth(user, password);
        request.setRequestHeader("Accept", "application/json");
        request.setRequestHeader('Content-Type', 'application/json');
        request.setRequestBody(JSON.stringify(data));
        var response = request.execute();
        gs.log(response.getBody());
    }
})(current, previous);

Instead of using endPoint function you should create the REST MESSAGE and call In your script

var request = new sn_ws.RESTMessageV2('YourRestMsgName','Post');

Regards,

Suresh.

Regards,
Suresh.

I hope I cleared your all queries. Can you mark it as the correct answer and help to close the thread. It will help for future readers.

Regards,

Suresh.

Regards,
Suresh.

Sure!

Thank you for your support !!