How to copy multirow variable set value in description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 07:44 AM
Hi Team,
We have 3 variable set on catalog item.
2 is single line and 1 is multiLine variable set.
I am creating change request from task and copying all variable in change description.
I am able to fetched single line variable set value by below code but unable to fetch multi row variable set.
var arr = [];
var ritm = new GlideRecord('sc_req_item');
ritm.get('sys_id', current.request_item);
var variables = ritm.variables.getElements();
for (var i = 0; i < variables.length; i++) {
var question = variables[i].getQuestion();
var label = question.getLabel();
var value = question.getDisplayValue();
arr.push(label + " : " + value + "" + "\n");
}
Can you please help me here how can I copy multirow variable set in description in below format ?
request by and additional info variable in single line variable set and After entry details all are in multirow variable set.
Requested by: Rick Mann
Additional info: Add info
Number of DNS entries requested: 3
Entry details:
Preferred name: test
Entry type: External
IP Address: 1.1.1.1
Zone: int.8451.com
----------------
Preferred name: Test2
Entry type: Internal
IP Address: 1.2.3.4
Zone: 8451.com
Please help me here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 07:57 AM
Hello @lucky24
Use this
And for your reference use this link as well-
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0743684
var mrvsRows = ritm.mrvs_name;
//The above will return a string in the form of array and objects. Now you will have to parse it
var oMrvs = JSON.parse(mrvsRows);
var desc;
for(var i in oMrvs) {
desc += oMrvs[i]["cost_field_name"];
..... give every field name of variable set
}
ritm.description = desc;
Please accept the solution and mark as helpful, if it helps you.