- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 05:28 AM
HI Community,
I have written a script but in variables it is not getting aligned correctly
script include:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 06:05 AM
update as this
getSapCatalogValues: function() {
var sap = this.getParameter('sysparm_sap');
var sapVal = {};
var gr = new GlideRecord("u_sap_catalog");
gr.addQuery("u_reference_number", sap);
gr.query();
if (gr.next()) {
sapVal['shortDescription'] = gr.getValue('u_short_description');
sapVal['description'] = gr.getValue('u_description');
sapVal['question'] = gr.getValue('u_questions');
sapVal['approval'] = gr.getValue('u_approval');
sapVal['group'] = gr.getValue('u_assignment_group');
}
return JSON.stringify(sapVal);
},
Client script
var answer = response.responseXML.documentElement.getAttribute("answer");
var parsedData = JSON.parse(answer);
g_form.setValue('title', parsedData.shortDescription);
g_form.setValue('description', parsedData.description);
g_form.setValue('questions_information', parsedData.question);
g_form.setValue('approval_details', parsedData.approval);
g_form.setValue('assignment_group', parsedData.group);
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
12-17-2024 05:34 AM
sorry didn't get your question.
very difficult to understand without screenshots.
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
12-17-2024 05:48 AM - edited 12-17-2024 05:49 AM
in catalog form there is a variable called referenec number on selecting the value then other variables like title, desc, question and info, approval and assignment group will get auto populated.
For this to work i have written a script as mentioned in post, data will be coming from sap catalog table.
If you see the image in question & information variable "Please provide following data along with request
1. Selection Parameters (e.g. GL Code, GL Code Desc, Co Code, Posting " this needs to be present but only "Please provide following data along with request
1. Selection Parameters (e.g. GL Code" is filled as there is , in the value it is getting breaked and remaining are filled in other variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 06:05 AM
update as this
getSapCatalogValues: function() {
var sap = this.getParameter('sysparm_sap');
var sapVal = {};
var gr = new GlideRecord("u_sap_catalog");
gr.addQuery("u_reference_number", sap);
gr.query();
if (gr.next()) {
sapVal['shortDescription'] = gr.getValue('u_short_description');
sapVal['description'] = gr.getValue('u_description');
sapVal['question'] = gr.getValue('u_questions');
sapVal['approval'] = gr.getValue('u_approval');
sapVal['group'] = gr.getValue('u_assignment_group');
}
return JSON.stringify(sapVal);
},
Client script
var answer = response.responseXML.documentElement.getAttribute("answer");
var parsedData = JSON.parse(answer);
g_form.setValue('title', parsedData.shortDescription);
g_form.setValue('description', parsedData.description);
g_form.setValue('questions_information', parsedData.question);
g_form.setValue('approval_details', parsedData.approval);
g_form.setValue('assignment_group', parsedData.group);
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