How to populate values in the multi row variable set variables without click on the "Add" button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 09:46 PM
How to populate values in the multi row variable set variables without click on the "Add" button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 10:54 PM
Hi @Shantharao ,
Please be more specific , do you want to populate on page load and based on what conditions only then anyone can help you out here.
Please mark correct/helpful if my response helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2024 01:20 AM
On Selection of Requested for variable, I want to auto populate the multi row variable set info as highlighted in the above screenshot, any hardcoded values also fine for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 11:04 PM - edited ‎11-26-2024 11:04 PM
Hello @Shantharao ,
You can use this Onload Client Script on catalog item to add default value:
function onLoad() {
var mrvs_data = {};
mrvs_data = setMRVStier1(1);
var oDetails = mrvs_data;
for (var sKey in oDetails) {
if (sKey == "set_row") { //add your Variable set Name
g_form.setValue(sKey, JSON.stringify(oDetails[sKey]));
}
}
}
function setMRVStier1(num) {
var obj = {};
var obj2 = {};
var obj3 = {};
var objArr = [];
for (var i = 1; i <= num; i++) {
obj = {
"name": "Test1", // variable Name and value
"phone_number": "123456789"
};
obj2 = {
"name": "User",
"phone_number": "2345678970"
};
obj3 = {
"name": "user2",
"phone_number": "1234567890"
};
objArr.push(obj, obj2,obj3);
}
return {
"set_row": objArr
};
}
function clearRows(sysIdMRWS) {
TableVariableService.removeAllRows(sysIdMRWS);
}
And also you can hide the ADD and Remove Button:
function onLoad() {
var vset = g_form.getField("set_row");
vset.max_rows_size = 6;
var htmlDoc = false;
setTimeout(function() {
disableButtons();
}, 6000);
}
function disableButtons() {
var my_var = g_form.getField("set_row");
my_var.max_rows_size = 0;
var btn = this.document.getElementsByClassName("btn btn-default");
for (i = 0; i < btn.length; i++) {
if (btn[i].innerText == 'Remove All') {
btn[i].style.display = 'None';
}
}
var btn = this.document.getElementsByClassName("btn-primary");
for (i = 0; i < btn.length; i++) {
if (btn[i].innerText == 'Add') {
btn[i].style.display = 'None';
}
}
// hide all x buttons
var y = this.document.getElementsByClassName("wrapper-xs fa fa-close");
var j;
for (j = 0; j < y.length; j++) {
y[j].style.display = 'none';
}
var btn = this.document.getElementsByClassName("wrapper-xs fa fa-close");
for (i = 0; i < btn.length; i++) {
btn[i].style.display = 'none';
}
}
Variable set:
Result:
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Pooja.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2024 01:22 AM - edited ‎11-27-2024 01:22 AM
I have used but didn't working as expected, the Object info not populating in the rows in the MRVS