Need a script to check assignment group manager name

jayaprakash1998
Tera Contributor

Hi All,

Can anyone please help me with a client script ?

Requirement :

If user select assignment group in incident then show alert message, alert message should have the name of the assignment group manager and assignment group name.

 

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@jayaprakash1998 Here is how you should configure an onChange client script on your incident form.

 

Screenshot 2023-10-30 at 11.25.16 PM.png

Here is the script.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    var assignment_group = g_form.getReference('assignment_group',callback);

	function callback(group){				
		g_form.setValue('assigned_to',group.manager);
		var manager = g_form.getReference('assigned_to',anotherFunc);
		function anotherFunc(caller){
			alert('Group Name: '+group.name + ' Group Manager: '+caller.name);
			g_form.clearValue('assigned_to');
		}
	}
    
}

Hope this helps.

View solution in original post

7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @jayaprakash1998 

 

Greetings!!

 

What error your are facing? Asking to script is not good, if you wrote your script and its not working , please share the script to support you.

 

Check this link:

 

https://www.servicenow.com/community/developer-forum/can-we-display-list-field-values-in-the-alert-m...

 

Or check this playlist:

 

https://www.youtube.com/playlist?list=PLi0Ik1xCDEbK5BJme5YSGZASvl0nkaFHn

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG  Thankyou 

Hi @jayaprakash1998 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Utpal Dutta
Tera Guru

Hi Jaya,

I agree with Atulya. But just to help you with the approach you can either use an asynchronous calling to the server to get manager value of assignment group or you can do a synchronous calling.

 

Example of asynchronous calling to server using (g_form.getReference(formula)):

 

g_form.getReference('requested_by',userLookup); //userLookup is a self invoking function

 

function userLookup(userRef){ //Function called with parameter
alert(userRef.email);
}

 

Synchronous calling to server includes creating a script include and then calling it in Client script using GlideAjax. I would recommend doing it only when you're getting a good amount of data which may take sometime.

 

For your use case you should use getReference and modify the script above according to your need in Client Script.

 

If my answer helps then please mark it Helpful or Correct!

 

Thanks,

Utpal