Assignment group should be mandatory when caller is VIP user on Incident form

Mukul Sharma
Tera Contributor

Hi,

 

I have below requirement and have to implement via UI policy. But it is working not working when caller change to VIP. However it is working fine for on load.

 

Assignment group should be mandatory when caller is VIP user on Incident form

 

Thanks,

Mukul

6 REPLIES 6

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Mukul Sharma ,

 

On Load UI policy Script will only work when form is loaded. In case when caller is changed u need to have a onChange Client script in place to validate & make the assignment group mandate.

 

Thanks,

Danish

 

AndersBGS
Tera Patron
Tera Patron

Hi @Mukul Sharma ,

 

Please also share a snip of your UI Policy configuration and UI Policy action.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi Ander,

 

Please look into below UI policy and UI policy script.

 

VIP_2.jpgVIP_1.jpg

 

Thanks,

Mukul

Hi @Mukul Sharma ,

 

Sorry the bit of delay to my response 🙂 The reason that the UI Policy doesn't work is, due to you need a server callable script to check the VIP status on the sys_user table. To do this you can create as below (tested in my PDI):

 

Client script:

AndersBGS_0-1701949270057.png

Script to be set in client script:

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

var user = g_form.getValue('caller_id');

	//call script include

	var ga = new GlideAjax('VIPChecker'); //scriptinclude
	ga.addParam('sysparm_name', 'checkVIP'); //method
	ga.addParam('userId', user); //parameters

	ga.getXMLAnswer(getResponse);

	function getResponse(response){
		var res = JSON.parse(response);
		console.log(res);
		console.log(res.vip);
		var vip = res.vip;
		console.log(vip);

	    if (vip === '1') {
        g_form.setMandatory('assignment_group', true);
    } else {
        g_form.setMandatory('assignment_group', false);
    }
	
	
		} 

		}

 

Script include:

AndersBGS_1-1701949308934.png

Script to be set in script include:

var VIPChecker = Class.create();
VIPChecker.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    checkVIP: function() {
        var userId = this.getParameter('userId');
obj = {};

		var grSysUser = new GlideRecord('sys_user');
		if (grSysUser.get(userId)){
		obj.vip =  grSysUser.getValue('vip');
	}
	gs.addInfoMessage(obj+JSON.stringify(obj));
	return JSON.stringify(obj);
	},

	type: 'VIPChecker'
});

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/