- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2018 04:09 PM
I've created some variables on a catalog item that are references to things like Manager name, location and department and then added an on load client script to populate the users information when the requesters name is inputted on the form.
What I would like to do is make the requesters manager, location and department read only. The problem I am getting is that when I've created a UI Policy Action it starts of read only but when the fields are populated they don't remain read only.
Is there a way to make them read only even after they have been populated?
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2018 08:34 AM
Ok. Use the below code with uses getReference Callback. Since GlideRecord is not a good practice to use in Client Script. Run this and let me know, if there are still issues.
Also confirm there is no other UI policy or client script that is marking these field editable?
function onChange(control, oldValue, newValue, isLoading) {
if(newValue){
var grUser = g_form.getReference('staff_name', popCallerInfo);
}
//Nested 'getReference' callback function for variable access
function popCallerInfo(grUser){
g_form.setValue('u_job_title' , grUser.title); //set job title
g_form.setValue('u_department' , grUser.department); //set department
g_form.setValue('u_location' , grUser.location); //set location
g_form.setValue('u_contact_number' , grUser.mobile_phone); //use mobile phone field to set contact number
g_form.setValue('u_manager_name' , grUser.manager); //set job title
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2018 04:53 PM
The UI policy should work fine. I guess there will be an issue with your script which populates these related fields. Can you share your script? Also I think it should be an onChange Client Script.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2018 03:11 AM
Please see script below. To confirm I meant onChange script.
function onChange(control, oldValue, newValue, isLoading) {
//Type appropriate comment here, and begin script below
var id = g_form.getValue('staff_name'); //get user name from order guide form
var grUser = new GlideRecord('sys_user');
grUser.get('sys_id',id);
//set variable values in order guide
if(grUser.get(newValue)) {
g_form.setValue('u_job_title' , grUser.title); //set job title
g_form.setValue('u_department' , grUser.department); //set department
g_form.setValue('u_location' , grUser.location); //set location
g_form.setValue('u_contact_number' , grUser.mobile_phone); //use mobile phone field to set contact number
g_form.setValue('u_manager_name' , grUser.manager); //set job title
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2018 08:34 AM
Ok. Use the below code with uses getReference Callback. Since GlideRecord is not a good practice to use in Client Script. Run this and let me know, if there are still issues.
Also confirm there is no other UI policy or client script that is marking these field editable?
function onChange(control, oldValue, newValue, isLoading) {
if(newValue){
var grUser = g_form.getReference('staff_name', popCallerInfo);
}
//Nested 'getReference' callback function for variable access
function popCallerInfo(grUser){
g_form.setValue('u_job_title' , grUser.title); //set job title
g_form.setValue('u_department' , grUser.department); //set department
g_form.setValue('u_location' , grUser.location); //set location
g_form.setValue('u_contact_number' , grUser.mobile_phone); //use mobile phone field to set contact number
g_form.setValue('u_manager_name' , grUser.manager); //set job title
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2018 02:17 AM
Thanks that has worked. I really appreciate that. Out of interest what is the reason a glide record is not good practice to use in a Client Script?
Thanks for your help,
Matt