How to copy MRVS data to excel sheet after submit the request in portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 03:44 AM
Hi All,
In Custom table after submit the request in portal the data is storing and we have an option called "Export Data" with this option we can download the excel form here all the data is copying in excel sheet but multi row variable set data is not copying how to achieve that any suggestion please thank you.
The above is custom table after submit the request the data is storing here that's fine.
In the above excel sheet I'm not able to see MRVS data that is not copying in Excel Sheet
How to resolve this issue any script I have to write? or anything I have to modify please guide me
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 03:47 AM
Hello
Can you please share your UI script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 06:49 AM
Hello Mohith,
Below Script I have written
download();
function download() {
var varquestion = '';
var varanswer = '';
var itemjoin = "";
var itemquestion = "";
var itemanswer = '';
var v;
var sortedArray = sortVariables(current.variables);
var a = {
"RITM NUmber": "ritm",
"Urgent field": "urgent",
"New field": "bpp_non_bpp"
};
var keys = Object.keys(a).toString().split(",");
var values = [];
for (var k = 0; k < keys.length; k++) {
values.push(a[keys[k]]);
}
for (var i in sortedArray) {
var my_record = current;
var toPrint = 'Options:\n';
var qa = new GlideRecord('question_answer');
// qa.addQuery('table_name', 'x_nooy_gbs_siam_gbs_request');
// qa.addQuery('table_sys_id', my_record.sys_id);
qa.addEncodedQuery('table_name=x_nooy_gbs_siam_gbs_request^table_sys_id='+my_record.sys_id+"^question.type!=5");
qa.query();
while (qa.next()) {
if (qa.value != '') {
var name = qa.question.name;
var label = qa.question.question_text;
var value = my_record.variables[name].getDisplayValue();
toPrint += ' ' + label + ": " + value + "\n";
itemquestion += label + "\t";
itemanswer += value + "\t";
}
}
}
varquestion += itemquestion + "\t";
varanswer += "\n" + itemanswer;
var finaloutput = varquestion + varanswer;
function sortVariables(variableArray) {
var sortedVariables = [];
var count = 0;
for (var i in variableArray) {
var object = {
index: i,
};
sortedVariables[count] = object;
count++;
}
sortedVariables.sort(function compare(a, b) {
return a.order - b.order;
});
return sortedVariables;
}
var attachfile = new GlideSysAttachment();
var file = attachfile.write(current, current.number + '.xls', 'test/csv', finaloutput);
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 07:02 AM
Hello
As per the script you are gliding to question_answer table to get the value and label of the variables on the form which is working fine for you
Bu the reason why MVRS values are not added was MVRS question and answer gets stored in different table but not question answer
The table is sc_multi_row_question_answer
var qa = new GlideRecord('question_answer');
qa.addEncodedQuery('table_name=x_nooy_gbs_siam_gbs_request^table_sys_id='+my_record.sys_id+"^question.type!=5");
qa.query();
while (qa.next()) {
if (qa.value != '') {
var name = qa.question.name;
var label = qa.question.question_text;
var value = my_record.variables[name].getDisplayValue();
toPrint += ' ' + label + ": " + value + "\n";
itemquestion += label + "\t";
itemanswer += value + "\t";
}
}
In this glide record you are gliding to question_Answer table
Please add another glide record to sc_multi_row_question_answer this table and push those label and values like above in same way
Find below screenshot
Please mark my answer correct if it helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2022 02:13 AM
if it solved your issue can you please mark my answer correct and close the thread