can you pls clarify the requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
how to do the 3rd step can you clarify clearly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
Hi @damodar
It is dot walk.
alm_hardware table --.Assigned to field is there
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
you will require onChange client script on Employee name reference field and bring the hardward assigned to that person and then set it
Something like this with GlideAjax
Script Include: it should be client callable
var GetUserHardwareAjax = Class.create();
GetUserHardwareAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getHardwareByUser: function() {
var userSysId = this.getParameter('sysparm_user_sys_id');
var hardwareRecord = new GlideRecord('alm_hardware');
hardwareRecord.addQuery('assigned_to', userSysId);
hardwareRecord.query();
if (hardwareRecord.next()) {
return hardwareRecord.getUniqueValue();
}
return '';
},
type: 'GetUserHardwareAjax'
});
Client Script: onChange of employee
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.clearValue('u_hardware'); // give here the correct field name
}
if (oldValue != newValue) {
var ga = new GlideAjax('GetUserHardwareAjax');
ga.addParam('sysparm_name', 'getHardwareByUser');
ga.addParam('sysparm_user_sys_id', newValue);
ga.getXMLAnswer(function(answer) {
if (answer != '')
g_form.setValue('u_hardware', answer); // give here the correct field name
else {
g_form.addInfoMessage('No hardware assigned to this user');
}
});
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @damodar
Try this (high level design) :
- Employee Name
- Type: Reference
- Reference Table: sys_user
- Reference qual condition: active=true^u_workday_integration=true
- Employee ID
- Type: String (Read-only)
- How to Populate:
- Set the Dependent question to the "Employee Name" field, and set the Dot walk path to employee_number /the field where you stored employee number (refer: Auto-populate a variable based on a reference type variable (Utah))
- Create an onChange Client Script on the Employee Name field using g_form.getReference() to fetch and set the value .Refer : https://www.servicenow.com/community/itsm-forum/auto-populate-fields-from-selected-user/m-p/604446
- Computer Name
- Type: Reference or String (Read-only)
- Reference Table: alm_hardware
- How to Populate:
- For Standard Forms: Create an onChange Client Script that triggers off the Employee Name field, pulling the primary computer field via a GlideAjax / getReference call.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti