- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 06:35 AM - edited 01-09-2025 07:48 AM
Im currently using a requested for variable on a catalog item. Im trying to populate the value of a string variable on the form with the value from the user record currently it works if you change the requested for and back again using OOTB features to auto populate a field. however when the requested for logs into the form from the order guide selection it does not populate. Anything i can do differently to achieve a auto population even from the initial load of the log in user?
The requested for variable was renamed to 'name'
the field on the user record im trying to pull is 'u_non_company_email'
the variable im trying to populate on load based on the requested for variable 'name' is 'non_company_email'
Script Include:
var requestor_details = Class.create();
requestor_details.prototype = Object.extendsObject(AbstractAjaxProcessor, {
requestor_info: function() {
var result = this.newItem("result");
var logged_user = gs.getUserID();
var user_detail = new GlideRecord('sys_user');
user_detail.addQuery('sys_id', logged_user);
user_detail.query();
while (user_detail.next())
{
result.setAttribute("user", user_detail.sys_id);
result.setAttribute("phone", user_detail.phone);
result.setAttribute("email", user_detail.email);
result.setAttribute("location", user_detail.location);
result.setAttribute("u_non_company_email", user_detail.u_non_company_email);
}
},
type: 'requestor_details'
});
Catalog Client Script:
function onLoad()
{
var ga = new GlideAjax("requestor_details");
ga.addParam("sysparm_name", "requestor_info");
ga.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var result = serverResponse.responseXML.getElementsByTagName("result");
var phone = result[0].getAttribute("phone");
var user = result[0].getAttribute("user");
var email = result[0].getAttribute("email");
var loc = result[0].getAttribute("location");
var non = result[0].getAttribute("u_non_company_email");
g_form.setValue('u_non_company_email', non);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 09:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 09:51 AM
Did you try using the variable Auto-populate feature - is that what you meant by OOTB features? Is the Client Script and Script Include an attempt to not use the Auto-populate feature? Are you getting any of the expected result attributes? It's not based on the requested_for variable as you are not passing that value from the Client Script to Script Include, so try adding that in place of getUserID() for the user details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 09:58 AM
The OOTB feature is the auto-populate feature yes. it does work if you change the requested for variable to a different name but only on change not on load. since the requested for variable defaults to logged in user it does not work. so far nothing populates on the email variable im attempting to pull from the requested for user record on load.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 09:55 AM
Try changing the ui type to all.