Removing all Add/Delete options from Multi-Row Variable Set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 05:13 AM
I have a Multi-Row Variable Set in a Catalog Item that we are displaying in the Service Portal. I am pre-populating it with exactly the number of rows it needs to have (that part is working great). So I want to remove all the Add/Delete options that are displayed so the only action they can take in it is to Edit the existing records.
I found an old thread here, that I tried to implement: https://community.servicenow.com/community?id=community_question&sys_id=478d90bb1bf48c10a59033f2cd4b.... It seems to remove everything I need except the "Add" button. It looks like maybe the code in that thread removes the add button after a set number of records in the MRVS. Can someone help me edit it so that the Add button is also removed right away.
Here is the block from my current code, found in the On Load event of my Catalog Item:
// hide remove button
setTimeout(function () {
var x = this.document.getElementsByClassName("btn btn-default");
//alert(x[4].getAttribute("ng-click"));
var i;
for (i = 0; i < x.length; i++) {
if (x[i].getAttribute("ng-click") == 'c.clearValue()' && x[i].getAttribute("type") == 'button'){
x[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';
}
//hide add button
var z = this.document.getElementsByClassName("btn btn-primary m-r");
//alert(z.length);
var k;
for (k = 0; k < z.length; k++) {
if (z[k].getAttribute("title") == 'You can add only 5,000 rows'){
z[k].style.display = 'none';
}
}
}, 1000);
So hiding the "Add" button is the last block above, as copied from that other thread. I see it has the title "You can add only 5,000 rows", but I don't see that value set anywhere in the code. So I am a bit confused.
Can anyone help?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 06:40 AM
Check the below link plz , where this has been addressed. You can set the condition exactly at when you want to trigger it.
Mark my ANSWER as CORRECT and HELPFUJL if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 06:58 AM
No, that link does not help. That deals with making the entire Multi-Row Variable Set read-only. That is not what I am trying to do. I only want to prevent them from adding or removing records from the MRVS. They need the ability to edit the current records. So we cannot make the entire MRVS read-only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2020 12:31 PM
Hi,
I have written an article on how you can disable the buttons in the MRVS. Kindly refer to this.
Mark the comment as a correct answer and also helpful if it helps to solve your problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2020 12:32 PM
In your code, instead of title, try accessing innerText and compare with Add.
Also check out the property max_rows_size of MRVS through which you can disable Add button.
