Multirow Variable Set returning backend values after submitting "Add" button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 02:45 AM
Hi Team,
I am facing issue where multirow variable set returning backend values after clicking on Add on the form. like below.
I am adding add option by splitting the response body from script include.
sdnd alert is what getting response from script include: BFS Operations LLB - 1110,BFS Group LLC (DE) - 1120,BFS Texas Sales LLC - 1130,BFS Texas Sales LLC - 1140,Spenard Builders AK - 1150,BFS Sales DC - 10,Plant Transfers DC - 20,BFS Common Division - 10
Client script:
Script include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 11:00 PM
"BFS Operations LLB - 1110,BFS Group LLC (DE) - 1120,BFS Texas Sales LLC - 1130,BFS Texas Sales LLC - 1140,Spenard Builders AK - 1150#@#BFS Sales DC - 10,Plant Transfers DC - 20#@#BFS Common Division - 10"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 11:00 PM
Make sure sales area,distChanrl,dname variable should be available on form.
function onLoad() {
var ga = new GlideAjax("OMNIUtils");
ga.addParam("sysparm_name", "getSDCD");
ga.getXML(getResponse);
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
var sdnd = answer.toString().split("#@#");
// Ensure the sdnd array has expected length
if (sdnd.length !== 3) {
gs.error("Unexpected response format: " + answer);
return;
}
var salesOrgs = sdnd[0].split(",");
var dNames = sdnd[1].split(",");
var divisions = sdnd[2].split(",");
// Ensure fields exist before adding options
if (g_form.getControl('salesarea')) {
for (var i = 0; i < salesOrgs.length; i++) {
var parts = salesOrgs[i].split(" - ");
if (parts.length === 2) {
g_form.addOption('salesarea', parts[1], parts[0]);
}
}
}
if (g_form.getControl('distributionchannel')) {
for (var j = 0; j < dNames.length; j++) {
var parts = dNames[j].split(" - ");
if (parts.length === 2) {
g_form.addOption('distributionchannel', parts[1], parts[0]);
}
}
}
if (g_form.getControl('dname')) {
for (var k = 0; k < divisions.length; k++) {
var parts = divisions[k].split(" - ");
if (parts.length === 2) {
g_form.addOption('dname', parts[1], parts[0]);
}
}
}
}
}