Received results in Script - Background with more message and I am not sure why I am receiving it.

NagaNandini N
Tera Guru

Hi All,

I have added one particular role to all users in ServiceNow using Scripts - Background.

I've included the code for reference. Script execution is done and I am getting results like this. Please take a look at the screenshot for reference. I am not sure why am I getting the below results"FAILED TRYING TO EXECUTE ON CONNECTION" Will it cause any issue in the PROD after implementing it ?

 

(function(){
var grUser = new GlideRecord("sys_user");
grUser.addActiveQuery(); // Get only active users
grUser.query();
while(grUser.next()){
var grMember = new GlideRecord('sys_user_grmember');
grMember.initialize();
grMember.group = "bc1c81351bdb3d100da14223cd4bcb3c";
grMember.user = grUser.sys_id;
grMember.insert();
}
})();

 

 

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi @NagaNandini N 

your code looks okay. However, you should also know that whatever error messages appeared in parallel during execution of the code will not only be printed in the syslog table but also in the output window. As your PROD is different, you might not have the same database issues there. And in case you have issues there, they do not necessarily have to do with the execution of your script.

Maik

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi @NagaNandini N 

your code looks okay. However, you should also know that whatever error messages appeared in parallel during execution of the code will not only be printed in the syslog table but also in the output window. As your PROD is different, you might not have the same database issues there. And in case you have issues there, they do not necessarily have to do with the execution of your script.

Maik

Thank you for the clarification. The error messages are displayed only in the DEV instance. On testing in the TEST instance, it worked perfectly without error. Thank you

 

Regards,

Naganandini N