Autopopulate SR details in catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2025 08:35 PM - edited 01-20-2025 01:34 AM
I have to create a catalog where if type_of_request is Shopping & Deployment and the requestor will choose the SR number on the variable field: indicate_the_assessment_quotation_ticket it should autopopulate the details of SR
- Labels:
-
Request Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2025 09:20 PM
Hi @alt ,
The sysparm_id is expecting the sysid of the sc_req_item.
assuming the variable indicate_the_assessment_quotation_ticket is referencing to sc_req_item
you should update the line no:5 in the client script as you are passing a constant value "indicate_the_assessment_quotation_ticket" and not a sysid that the script is expecting
function onChange(control, oldValue, newValue, isLoading) {
var req_for = g_form.getValue('sc_req_item');
var ga = new GlideAjax('GetVariableDetails');
ga.addParam('sysparm_name', 'GetVariableDetails');
ga.addParam('sysparm_id', g_form.getValue('indicate_the_assessment_quotation_ticket'));
ga.getXML(RequestorParse);
function RequestorParse(response) {
var answerXML = response.responseXML.documentElement.getAttribute('answer');
if (answerXML) {
g_form.addInfoMessage("Answer XML: " + answerXML);
var reqItemDetails = JSON.parse(answerXML);
g_form.addInfoMessage("Parsed Details: " + JSON.stringify(reqItemDetails));
if (reqItemDetails) {
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 || "");
} else {
g_form.addErrorMessage("Parsed details are undefined.");
}
} else {
g_form.addErrorMessage("Failed to get a valid response from the server.");
}
}
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya