Auto Populate user's email on catalog item field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2025 10:57 PM
I’m creating a Service Catalog item and I have a variable to capture the requester’s email. How can I automatically populate this variable with the logged-in user’s email when the form loads?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2025 12:27 AM
Hi @pathumh09586800
Its easy one.. Let me send you the video:
the below will help
https://www.youtube.com/watch?v=4unHkSkkT70&list=PLKH9bPqlw1neGCJbunoZl7ag-zYxyi8Oe&index=7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2025 12:31 AM
Hi @pathumh09586800
You can use the below Sample Code As well
Create a Script Include
-
Name: GetUserInfo
-
Check Client Callable = true.
var GetUserInfo = Class.create();
GetUserInfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserEmail: function() {
var userId = gs.getUserID(); // logged-in user sys_id
var gr = new GlideRecord('sys_user');
if (gr.get(userId)) {
return gr.getValue('email'); // return the email address
}
return '';
}
});
Create a Catalog Client Script
-
Type: onLoad
-
Applies to: your catalog item.
var ga = new GlideAjax('GetUserInfo');
ga.addParam('sysparm_name', 'getUserEmail');
ga.getXMLAnswer(function(response){
var email = response;
g_form.setValue('requester_email', email);
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2025 12:49 AM
you can use default value like this in variable and no other scripting required
javascript: gs.getUser().getEmail();
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2025 05:18 AM
Hi Ankur,
Under which variable name did you include this script.
I'm trying to create a simple request form where I want the email field to be automatically populated when a name is selected in the name field.
Currently my name field is a reference field and email field is a read only single line text. See screen print.
Appreciate your valuable advice.