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

Gurpreet07
Mega Sage

It's partially true. yes, I want you to look at example UI actions for how RP.isRelatedList() is used to show that UI Action only on related lists. I don't want you to so something on ui action but create an acl on related table with a script....


if(RP.isRelatedList() && ifScript()){                 // ACL will be applied only for related list


answer = true;


}



function ifScript(){


//check state of parent record and return true/false


}