Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Integration

kirankr2061
Tera Contributor
var apipath = '/api/now/table/sys_user_grmember';
var username = 'Automation';
var pass = 'xxx';
var asgrpid = 'e666528b939e2ad4e2cb3af17cba109a'; // Group sys id in qa
var value = '84a4d1df87758510735aba2c8bbb3559'; // User sys id

var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('POST');
r.setEndpoint(qaurl + apipath);
r.setRequestHeader('Accept', 'application/json');
r.setRequestHeader('Content-Type', 'application/json');
r.setBasicAuth(username, pass);

var body = {
    "group": asgrpid.toString(),
    "user": value.toString(),
};

r.setRequestBody(JSON.stringify(body));
gs.print("Request body: " + r.getRequestBody());

var response = r.execute();
var statusCode = response.getStatusCode();
var responseBody = response.getBody();

gs.print("Status: " + statusCode);
gs.print("Response: " + responseBody);

var parsed = JSON.parse(responseBody);
if (parsed.result) {
    gs.print("Created sys_id: " + parsed.result.sys_id);
}
I am trying to give access to other people from my instance but problem is record is getting created with empty values please suggest me any solution
4 REPLIES 4

GlideFather
Tera Patron

Hi @kirankr2061,

 

if you want to give access to your PDI for other people, then create their user profiles and set passwords and they will have the access as per granted to them (portal x backend etc).

 

What's the code above about?

_____
This reply is 100 % GlideFather and 0 % AI

Through a catalog item request I am trying to give access to others 

@kirankr2061 
And why don’t you add the access through a group membership?

_____
This reply is 100 % GlideFather and 0 % AI

He is existing user I just need to give access to those