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.

PrashantLearnIT
Giga Sage

Hello Everyone,

 

Use Case Scenarios for requirement fulfillment in our day-to-day development activities.

 

Server-Side Scripts Used for Demo Purpose -

 

var users = ['7d9a8d6ac3b85a10440478edd401318c', 'ddaa05eac3b85a10440478edd40131da', 'aaaac9aec3b85a10440478edd40131c4', '37aa8daec3b85a10440478edd4013182', '01ba0daec3b85a10440478edd4013143']; // You can add any number of user arrays in my case I have used 5, you can pass dynamic array list here

 

var groups = ['aaba01eec3b85a10440478edd4013141', '0dcacdaec3b85a10440478edd4013131', '56ca8daac3b85a10440478edd401314a', '23cacdaec3b85a10440478edd4013101', 'b1da01eec3b85a10440478edd4013148']; // You can add any number of Group arrays in my case I have used 5, you can pass dynamic array list here

 

for (var i = 0; i less than groups.length; i++) {
var groupSysId = groups[i];

for (var j = 0; j less than users.length; j++) {
var userSysId = users[j];

var grMember = new GlideRecord('sys_user_grmember');
grMember.initialize();
grMember.group = groupSysId;
grMember.user = userSysId;
grMember.insert();

gs.info('Added User ' + userSysId + 'to group ' + groupSysId);
}

}

For the Demo please have a look at the following video - 

 

 

Best Regards,

Prashant Kumar (LearnIT)

 

YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant

Blog LearnIT: https://medium.com/@LearnITbyPrashant

Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/

ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635