Auto populate "requested for" email id and manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:17 AM - edited 06-07-2024 12:19 AM
Hi @karunasrikuna,
You can help with this below thread:
Note: email variable should be reference one, it should be string type and try to visible false.
Please accept my solution if it works for you and thumps up.
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:19 AM - edited 06-07-2024 12:20 AM
@karunasrikuna - We have the OOTB feature in the variable form under the section "Auto Populate". Please refer to the screenshot that helps you to auto populate the value based on the reference field in your catalogue item.
More information from documentation : https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man...
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:19 AM
You can achieve this by creating an onChange catalog client script and client callable script include.
// OnChange client script, should run on change of Requested for Variable
var ga = new GlideAjax('Script Include name');
ga.addParam('sysparm_name','getUserDetails');
ga.addParam('sysparm_userId', g_form.getValue('requested_for'); //type correct name of your variable.
ga.getXML(ResponseFunction);
function ResponseFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var results = JSON.parse(answer);
g_form.setValue('firstName',results.firstName);
g_form.setValue('lastName',results.lastName);
g_form.setValue('manager',results.manager);
g_form.setValue('email',results.email);
g_form.setValue('title',results.title);
}
//Script Include
getUserDetails: function() {
var userID = this.getParameter('sysparm_userId');
var user = new GlideRecord('sys_user');
user.get(userID);
var obj ={};
obj.firstName = user.first_name;
obj.lastName = user.last_name;
obj.manager = user.manager;
obj.email = user.email;
obj.title = user.title;
return JSON.stringify(obj);
}
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:27 AM
Hi @karunasrikuna ,
Please refer below thread -
If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having
Thanks,
Astik