Trouble with submitproducer API in scope application

richardphon
Tera Contributor

Hello,

I have a requirement to create a record producer when a record is inserted to a custom table.

 

I use the submitproducer API. All is working fine in the global application scope (the record producer is created with variables filled). But when i use a record producer that is in the customer service application scope, nothing is created.

 

here's the code :

 

(function executeRule(current, previous /*null when async*/) {

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://mydboxdev.service-now.com/api/sn_sc/servicecatalog/items/b919466b87928610ba0e4157cebb351d/su...');
request.setHttpMethod('POST');

var bat = current.getValue('u_batiment');
var site = current.getValue('u_site');
var etage = current.getValue('u_etage');
var contact = current.getValue('u_contact');
var num = current.getValue('u_numero');
var compte = 'b4886d411b3891103901eb91604bcb5e';

var body = {'variables':{"account":compte,"site":site,"batiment":bat,"contact":contact,"numero_du_contact":num,"etage":etage}};

request.setBasicAuth('login','password');
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
request.setRequestBody(JSON.stringify(body));
var response = request.execute();

})(current, previous);

 

Than You for your help.

 

Richard.

2 REPLIES 2

Kieran Anson
Kilo Patron

Out of curiosity, are you making this API call to another servicenow instance, or the same servicenow instance as the business rule is running?

richardphon
Tera Contributor

Hello,

Sorry for the late answer. I am calling the API on the same instance that the business rule is running.