I would like a true/false field on the requested item table to be auto-ticked (true) depending on who the requestor is (opened by field).

Abbie2
Tera Contributor

I would like a true/false field on the requested item table to be auto-ticked (true) depending on who the requestor is (opened by field).

We have 5 users who are classed as 'external' users, and so when they submit a request, we would like this box to be auto-ticked.

I am not very good at scripting and I am new to ServiceNow developing, so any help would be very appreciated.

1 ACCEPTED SOLUTION

Dan H
Tera Guru

Hi,

Business rule running on Requested Item table

find_real_file.png

find_real_file.png 

Script:

(function executeRule(current, previous /*null when async*/) {

	var caller = current.opened_by;
	
	var externalUsers = ['c6445481eb310100fcfb858ad106fef1', '61b07c8973200010c2e7660c4cf6a7d0'];
	
	for(i = 0; i < externalUsers.length; i++){
		if(caller == externalUsers[i]){
			current.u_checkbox = true;
		}
	}

})(current, previous);
  • Just add the 5 users sys id's into that script and replace the two that are currently in there.
  • Change 'u_checkbox' to the name of your true/false field

 

Hope this helps.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

View solution in original post

4 REPLIES 4

Jon23
Mega Sage

Try using a simple business rule on insert where your condition builder can evaluate the opened_by is external and the action is set the request true/false field.

Dan H
Tera Guru

Hi,

Business rule running on Requested Item table

find_real_file.png

find_real_file.png 

Script:

(function executeRule(current, previous /*null when async*/) {

	var caller = current.opened_by;
	
	var externalUsers = ['c6445481eb310100fcfb858ad106fef1', '61b07c8973200010c2e7660c4cf6a7d0'];
	
	for(i = 0; i < externalUsers.length; i++){
		if(caller == externalUsers[i]){
			current.u_checkbox = true;
		}
	}

})(current, previous);
  • Just add the 5 users sys id's into that script and replace the two that are currently in there.
  • Change 'u_checkbox' to the name of your true/false field

 

Hope this helps.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Abbie2
Tera Contributor

Thank you so much! 

Hello Abbie

If that users are static ,Instead of following a script approach you can follow no script which can help on your Instance health 

Build Below Condition

Opened by is "User Name 1"

AND

Opened by is "User Name 1"

AND

......

Go to Action Tabs

Select Checkbox name and set as True

Please mark my Answers Helpful if it helps in resolving your Query

Thanks

Hemant Kumar Ch