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

Ok



Let me give you more context


This is something I've done on my instance.


z2.png



Click list control and on the form change the layout.


On the form change the layout in order to introduce the new field




z3.png



Cheers


R0b0


I don't have an Omit insert row condition option like you do.   Even by going to Form Layout, there's nothing in the left-hand column that says that:



find_real_file.png


Ivano B
ServiceNow Employee
ServiceNow Employee

Hi David



I have the same view as yours only if i have the related list on the form.



z4.png



z5.png



Not sure if the reason is the fact that you are using a custom table but it doesn't make sense...just last question..


Which version of ServiceNow are you using ?



Cheers


R0b0


Yes, the related list is on the form, so I'm stumped too .   I'm running Helsinki (latest patch)


I'm on Helsinki btw... don't know if "Omit insert row condition" is a Jakarta+ thing