Servicely Administration
Scripting
Table API (Client)
6 min
overview to interact with specific fields on the form on the client side, we have a variety of functions and methods you can use to make fields read only, required and more the majority of these can be accessed in the following way where if there are exceptions, it will be explicitly mentioned //commonly in this format current \<fieldname> \<functionname>(); //as an example, this would work current requestedfor required(true); you can also set the value of a field by passing it in as a parameter, such as the following //normal format to set a value current \<fieldname>(\<value>); //as an example, this would work current shortdescription("this is a short description"); in addition to this, on the client side you can get the display value and actual value of fields although for some fields, values will be the same as the display values (such as strings), this will not be the case for reference fields to get a field’s value or display value, you can do the following //to get the underlying value of a field current \<fieldname>() //as an example, this would work this would return an id current requestedfor() //for the display value, you could do the following current \<fieldname>> displayvalue() //as an example, this would work this would return a name current requestedfor displayvalue() functions available function returns description existsonform() boolean this returns whether or not the field shows up on the form fieldlabel() string this returns the field’s label as a string fieldtype() string this returns the field type as a string getcssclass() string this returns the css class that has been applied via a ui event or otherwise readonly(boolean) n/a this makes a field read only required(boolean) n/a this makes a field mandatory / required setcssclass() n/a this sets the class of a field (which you can add as a portal style or otherwise) visible(boolean) n/a this shows / hides a field on the form ignorehaschanged(boolean) n/a allows a field to be set by a script, but will not cause the form to be marked as ‘dirty’ layout element behaviour to use this functionality, you need to be on version 1 10 or later in certain situations, you may wish to hide and show a whole section or specific layout element, which is not a field this includes items such as headings, information panels, tabs and more to achieve this, we have added an additional function to the current object getuielements("\<formid>") to understand how this works this article will use a specific example as an initial step, the layout element you wish to show / hide, will need to be given a “form id” this can be done by going to the form builder, hovering over the layout element in the form builder, clicking on the gear and giving it a “form id” then, within a ui event, you can refer to it and show and hide accordingly such as, if i wish to hide the container this refers to current getuielements("authentication container") visible(false); however, if i want to make it visible again (such as if a field changes current getuielements("authentication container") visible(true); as of today, only the visible() function is an option