Autopopulating fields in Backend but not in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 01:32 AM
Hi, I need help in auto populate as it is working on the backend but not in service portal
Client Script:
Back End:
Service Portal:
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 01:55 AM - edited 01-20-2025 01:58 AM
Check the client script UI type in the backend , is it selected to work only on DESKTOP or All .
If not make the change .
I hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 02:36 AM
ensure UI type-ALL for your client script
Also try to use getXMLAnswer()
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('GetVariableDetails');
ga.addParam('sysparm_name', 'GetVariableDetails');
ga.addParam('sysparm_id', newValue);
ga.getXMLAnswer(function(answer){
if (answer) {
try {
var reqItemDetails = JSON.parse(answer);
g_form.setValue('dmr_cost_center', reqItemDetails.dmr_cost_center || '');
g_form.setValue('cost_center', reqItemDetails.cost_center || '');
g_form.setValue('dmr_department', reqItemDetails.dmr_department || '');
g_form.setValue('department', reqItemDetails.department || '');
g_form.setValue('dmr_location', reqItemDetails.dmr_location || '');
g_form.setValue('location', reqItemDetails.location || '');
g_form.setValue('meeting_room_name_or_number', reqItemDetails.meeting_room_name_or_number || '');
g_form.setValue('purpose_of_installation', reqItemDetails.purpose_of_installation || '');
} catch (error) {
g_form.addErrorMessage("Error parsing JSON response: " + error.message);
}
} else {
g_form.addErrorMessage("Failed to get a valid response from the server.");
}
});
}
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
01-20-2025 08:24 PM
it is All still not showing in SP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 08:46 PM
what debugging did you do?
did the script include call happen? Did you see some logs in script include?
what came in alert for the answer?
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