Assignment group should be mandatory when caller is VIP user on Incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 12:03 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 12:07 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 12:07 AM
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 12:35 AM
Hi Ander,
Please look into below UI policy and UI policy script.
Thanks,
Mukul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 03:42 AM
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:
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:
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/