Auto-Populate the Assigned to field if similar Serial number is found in system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:00 AM
Hi All,
we want to auto populate a singleline text box field with the assigned user name if the serial number entered in the form already exist
Attached is the screenshot of the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 09:28 PM
Hi @Preksha Kapoor ,
Did you check my response?
If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:56 AM
you can have onChange on Serial Number variable and query alm_asset table and bring the Assigned to user
Something like this
Script Include: It should be client callable
var AssetUtils = Class.create();
AssetUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAssignedTo: function() {
var assetGR = new GlideRecord('alm_asset');
assetGR.addQuery('serial_number', this.getParameter('sysparm_serialnumber'));
assetGR.query();
if (assetGR.next()) {
return assetGR.assigned_to.sys_id;
}
return '';
},
type: 'AssetUtils'
});
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('AssetUtils');
ga.addParam('sysparm_name', 'getAssignedTo');
ga.addParam('sysparm_serialnumber', newValue);
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('assigned_toVariable', assignedTo);
} else {
g_form.clearValue('assigned_to');
g_form.addErrorMessage('No asset found with the provided serial number.');
}
});
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 09:49 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2025 12:03 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader