- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2014 09:02 AM
Hi All,
I have a UI policy that sets a few fields mandatory when a service alert is at post mortem stage. Our change manager has asked if these fields cannot be mandatory for him.
What would be the best way to action this? Can i set a true/false script inside the UI policy?
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2014 03:27 AM
Managed to get it to work. I used the following code:
function onCondition() {
var grpName = 'Service Assurance';
var usrID = g_user.userID;
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', grpName);
grp.addQuery('user', usrID);
grp.query(groupMemberCallback);
function groupMemberCallback(grp){
if(grp.next()){
g_form.setMandatory('u_actions_taken', false);
g_form.setMandatory('u_lessons_learned___proactive_', false);
g_form.setMandatory('u_root_cause', false);
g_form.setMandatory('u_updated_documentation', false);
g_form.setMandatory('u_vendor_report', false);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2014 10:52 AM
You could use the UI Policy scripts and then just use an if statement to check for the change manager's sys_id, but if you did that you would have to remove the UI Policy Actions and use g_form.setMandatory inside of the UI Policy scripts. It might be easier to put this into an onLoad script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2014 11:23 AM
You can place the below script in your UI policy and make sure that "on Load and run scripts" options are checked.
Script:Place the below script in "Execute if true" condition script
function onCondition() {
var changemanager = g_user.userID;
if(changemanager == '6816f79cc0a8016401c5a33be04be441')//replace sysid here with the change manager sysid in your instance
{
g_form.checkMandatory = false;//make all mandatory fields false for the change manager.
}
}
Let me know the outcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2014 01:31 AM
Hi Pradeep,
My fault in not explaining my question clear enough. I need this to be for anyone in the change management group not just for one person.
I guess i would still take their user id but then look up their groups?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2014 03:27 AM
Managed to get it to work. I used the following code:
function onCondition() {
var grpName = 'Service Assurance';
var usrID = g_user.userID;
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', grpName);
grp.addQuery('user', usrID);
grp.query(groupMemberCallback);
function groupMemberCallback(grp){
if(grp.next()){
g_form.setMandatory('u_actions_taken', false);
g_form.setMandatory('u_lessons_learned___proactive_', false);
g_form.setMandatory('u_root_cause', false);
g_form.setMandatory('u_updated_documentation', false);
g_form.setMandatory('u_vendor_report', false);
}
}
}