Creating Standard Change using sn_chg_rest REST API scope

Chito
Kilo Explorer

Using the REST API api/sn_chg_rest/change/standard I am getting the following error. 

{
    "error": {
        "message": "Cannot convert null to an object.",
        "detail": "TypeError: Cannot convert null to an object. (sys_script_include.7b2c3918b713130096c3e4f6ee11a93d.script; line 19)"
    },
    "status": "failure"
}

If I call the script using user account with ITIL role its OK. 

Without using the ITIL role what permissions to which tables do I need to define?   I have so far given read,write,create permissions to a user defined role to tables - change_request, std_change_record_producer, std_change_template and std_change_producer_version

11 REPLIES 11

panhao
Kilo Explorer

I'm sorry. I'm a beginner, too

Priya Shid1
Kilo Guru

Hi chito,

According to me this is happening because message and details does not contain any value so that it is not getting converted to JSON data.

 

 

Please mark if that helps to you!!

Chito
Kilo Explorer

Not really.  As I mentioned, if I make the call using a user with ITIL role it is completing successfully. 

Here's the snippet of the script include that mentioned in the error:

//

var StandardChangeTemplateSNC = Class.create();

StandardChangeTemplateSNC.CHANGE_RECORD_PRODUCER = "std_change_record_producer";
StandardChangeTemplateSNC.CHANGE_TEMPLATE = "std_change_template";

StandardChangeTemplateSNC.prototype = Object.extendsObject(ChangeProcess, {

initialize: function(_gr, _gs) {
ChangeProcess.prototype.initialize.call(this, _gr, _gs);
},

applyToChange: function(changeRequestGr) {
if (!changeRequestGr)
return false;

changeRequestGr.std_change_producer_version = this.getGlideRecord().current_version + "";

if (GlideDBObjectManager.getTables(this.getGlideRecord().getTableName()).contains(StandardChangeTemplateSNC.CHANGE_RECORD_PRODUCER))
return new GlideTemplate.getFromRecord(this.getGlideRecord().template.getRefRecord()).apply(changeRequestGr) === 0 ? true : false;
return false;
},

type: "StandardChangeTemplateSNC"
});

StandardChangeTemplateSNC.findById = function(sysId) {
if (!sysId)
return null;

var changeRecordProducerGr = new GlideRecordSecure(StandardChangeTemplateSNC.CHANGE_RECORD_PRODUCER);
if (!changeRecordProducerGr.get(sysId))
return null;

return new StandardChangeTemplate(changeRecordProducerGr);
};

StandardChangeTemplateSNC.findAll = function(orderBy, textSearch) {
orderBy = orderBy || ChangeProcess.NAME;

var changeRecordProducerGr = new GlideRecordSecure(StandardChangeTemplateSNC.CHANGE_RECORD_PRODUCER);
changeRecordProducerGr.addActiveQuery();
changeRecordProducerGr.addQuery("retired", false);
if (textSearch !== undefined && textSearch !== "undefined" && textSearch.trim() !== "")
changeRecordProducerGr.addQuery("template.name", "CONTAINS", textSearch).addOrCondition("template.short_description", "CONTAINS", textSearch);
changeRecordProducerGr.orderBy(orderBy);
changeRecordProducerGr.query();
return changeRecordProducerGr;
};

//

Harsh Vardhan
Giga Patron

if you will allow non itil users to create change request, it will again take huge changes on existing ACL configuration,