The CreatorCon Call for Content is officially open! Get started here.

Remove ability to insert new row on condition

xiaix
Tera Guru

When the "Status" is submitted, I need to take away the ability to "Insert new row..." on a related list:

find_real_file.png

The only time a user should be able to insert a new row would be if the status is NOT submitted.

I tried doing it by manipulating the DOM:

function onLoad() {

    document.onreadystatechange = function()   {

            if (document.readyState === 'complete')

            {

                    if (g_form.getValue('u_status') == 'Submitted')

                    {

                            var e = document.getElementsByClassName('list_unsaved list_row list_add');

                            setTimeout(function(){ e[0].parentNode.removeChild(e[0]); }, 1000);

                            if (e.length)

                                    e[0].parentNode.removeChild(e[0]);

                    }

            }

    };

}

Which worked, but 2 issues:     1) It's a bad way of doing it, and 2) if a user clicks a header of the related list to sort, then the "Insert a new row..." re-appears.

20 REPLIES 20

Ivano B
ServiceNow Employee
ServiceNow Employee

Hi David



Quick question. Is there a specific reason to have the list on the form and not as related list ?


I mean using a related list you can simply set up a condition on parent and remove the button in case the parent.state has that specific state.



Cheers


R0b0


First, it is a related list.   Second, there is no button to remove.



I was thinking an ACL would be the way to go, but it would affect the entire table


Ivano B
ServiceNow Employee
ServiceNow Employee

Other wise you can simply right click on the list and check for the list control form.


Right click on the form to check the hidden fields.


Anyway you will be able to see something like this...



z1.png



Than field should solve your issue



Cheers


R0b0


This is my list control:



find_real_file.png




I don't have an Omit insert row condition option like you do.