How to set category which is based on user location in standard proposal change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 09:58 PM
In Standard change proposal we have a category field which has 2 values 1. Automated Change 2. NZ Automated Change, How to set the value if the user location is global it should set Automated change and if the user location is NZ then the value should set to NZ Automated change. Please suggest
Category field is reference field please find the below screenshot
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 10:33 PM
Hi,
You can go for UI Policy in this case as below
Table - Change Request
Condition - Type is Standard AND
(Opened By (user) --> Location --> Name) is Global
//opened_by.location.field_name (which contains global on location table)
Then in Run Script
Execute if true : g_form.setValue('category','Automated Change'); //check the field name and value
Similar for other scenario.
Mark this as Helpful/Correct, if Applicable.
Regards,
Sourabh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 10:52 PM
Hello,
Please write onchange client script and make sure it runs on 'on load' as well, below is the sample code please tweak it accordingly, You have to call script include then set the values.
OnChange client script contains below-mentioned code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var userSelected = g_form.getValue('u_user');
var userDetails = new GlideAjax('UserDetailsUtil'); //script include UserDetailsUtil
userDetails.addParam('sysparm_name', 'getUserDetails'); //calling function getUserDetails
userDetails.addParam('sysparm_userSelect', userSelected); //passing the user detail as a parameter
userDetails.getXML(myid);
function myid(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'global')
{
g_form.setValue('subcategory' , add value here);
}
else
{
g_form.setValue('subcategory' , add value here);
}
});
}
UserDetailsUtil is the name of Script Include and since it is being called from a client script, it should be client callable. Below code is part of script include:
var UserDetailsUtil = Class.create();
UserDetailsUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserDetails: function(){ //definition for getUserDetails function, called from client script
var userObj = {}; //declaring user object
var gr = GlideRecord('sys_user'); //gliding through the user object
if(gr.get(this.getParameter('sysparm_userSelect'))){ //fetching user data from the parameter passed from client script
var ee = gr.location;
}
return ee; //returning the user defined object with details
},
type: 'UserDetailsUtil'
});
Mark my answer as correct or hit like based on impact.
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2022 10:55 PM
Hi Sadashiva,
In Standard change proposal, a basic template can be provided to set one value. To achieve the category autopopulate on based on user's location you can use client script (onload and onchange) of the user and check the location to set the category.
Please mark helpful if it is useful for you!