Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

I'm on Helsinki as well



Cheers


R0b0


Well, r0b0_d3vil, you've been more than helpful and responsive, and I truly appreciate it!   It appears that I may need to open a HI ticket to find out why I'm not seeing this option.



In the meantime, can you link me official documentation on the "Omit insert row condition" field?   I can't seem to locate it anywhere on the wiki or the new docs (https://docs.servicenow.com)


I did notice this in your post:


find_real_file.png



Yours says "Embedded" list control.   Mine doesn't:



find_real_file.png




Maybe this?: Embedded List Control


Ivano B
ServiceNow Employee
ServiceNow Employee

Hi David



To be honest with you i didn't change any ACL.


Simply added the list on the form and not as related list.


This will give you automatically the other form, the one you highlighted.



is it yours a related list ? I'm confused



Cheers


R0b0


Ahh.. ok, so on my form I am doing a "related list".   That's the problem, I'm not "embedding" it.   Now I just need to figure out how to bring in the related list without it being a "related list".. lol.     ::scratches head::