Posts

How to hide a Related List

Do you know about the Related List that displays people who can approve or reject a document? Recently a scenario came up where the developer needed to prevent the employee who created a record from approving that document. It wasn't common because usually the operational level creates the document while a manager approves it. Leaving this question of personas aside and focusing on the problem, what would be a possible solution? The first workaround that came to my mind was to hide the Approval list if the user who registered was viewing his own record. A workaround is not the ultimate solution. Just a palliative fix while we find time to think about the ideal one. The action plan 1) Every record has a field called sys_created_by; 2) On the front-end (client side) we have access to an API called Glide User that has some information about the logged in user. Among them is the name in the userName property. What if we create a

How to fix a reference to the Choice [sys_choice] table

Image
        The Choice table is used internally by the platform and depending on the payload of an operation, for performance reasons the platform can decide that it is better to drop the table and insert all the values instead of perform updates on specific records.       When we insert a new record in a table, a new sys_id is generated. If we have the Choice table as a reference to provide choices for a particular field in our table, these choices will be lost every time the platform decides to recreate the Choice table.       A simple way to avoid this problem is to create a field of  type Choice  which indirectly uses the Choice table but it is the right way, or we can create our own table to maintain the Application choices.       Recently I received the mission to do exactly this: create a private choice table for an Application.     The problem       A long time ago, the platform allowed a developer to choose the Choice table as a reference.       As a consequence, old custom applic

There is a table called sys_choice and it is important to know everything you can about it

Image
     The Choice table - which has the internal name sys_choice - is used internally by the ServiceNow platform every time we create a field of type Choice and specify the available choices.        Points to remember when creating a choice       Always use only lowercase and underscores to form the Column name.         The Column label is what appears for the end user so you are free to use uppercase and spaces.       Use the same logic to create a choice. The value is internal and should contain only lowercase and underscores. The Label is what appears for the end user so you are free to use uppercase and spaces.        What you should never do       Never specify the Choice table as a reference in a Reference field. For example:       A reference field stores the sys_id of the corresponding record in the reference table. Since the Choice table is a core internal table, its behaviour is different from custom tables and the sys_ids can change.       The problem: when a sys_id in a refer