Script to get currently deactivating multiple users sys_id

Deepa12
Tera Contributor

Hi,

 

I deactivated multiple users into list view (drag the row by selecting multiple rows) and printing these users name through Business RUle. The script 

 var userSysId = current.sys_id.toString(); is fetching only one user name instead of all of the below listed 5 users name. Please advise the server script to get currently deactivating multiple users list. Thanks.

 

Deepa12_0-1737461403721.png

 

 

Deepa12_1-1737462093584.png

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepa12 

ideally the BR should run 5 times for 5 different updates or users

Did you try doing for 2 records?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepa12 

the BR should run 5 times and print 5 different times

How many times the BR log is printing?

where is the line which prints the sysId in logs?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi @Deepa12 

Business Rule script is executes for each deactivated user, and the user’s name will be printed in the System Logs (accessible via System Logs > All).

 

You can List Action, If you want to deactivate users in bulk and trigger the printing of their names without manually selecting each user.

In list view of user table, choose Personalize List > Create List Action.

script in List action:

(function execute(inputs, outputs) {

var users = inputs.records;


for (var i = 0; i < users.length; i++) {


var user = users[i];
user.active = false;
user.update();

gs.info('User deactivated: ' + user.name);


}
})(inputs, outputs);

 

IronPotato
Mega Sage

Hi @Deepa12 ,

 

change it from BR to Client Script with "Type" onCellEdit()

 

IronPotato_0-1737467715599.png

You have all selected sys_ids available, react on changed value and display message.

 

If my answer helped you in any way, please then mark it as helpful and correct. This will help others finding a solution.