You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 67 Next »

The SimpleForm API provides methods for customizing forms. These methods can be used on the client side only.

You can also use these methods to configure the dependencies between fields and values (for example, changing values in the fields or clear the fields).

s_form(table, sys_id)


Instantiates a new SimpleForm object.

NameTypeMandatoryDefault Value
tableStringYN
sys_idStringYN

s_form.addErrorMessage(message)


This method displays the error message at the top of the form.


Parameter(s):

NameTypeMandatoryDefault Value
MessageStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addErrorMessage
s_form.addErrorMessage('Need more information');

s_form.addInfoMessage(message, duration)


This method adds an informational message to the top of the form. The message is expirable, its expire period (in milliseconds) should be specified by $duration parameter.


Parameter(s):

NameTypeMandatoryDefault Value
messageStringYN
durationNumberYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addInfoMessage
s_form.addInfoMessage('Record successfully created', 1000);

s_form.addOption(fieldName, choiceValue)


This method adds a choice option to the end of the choice list field.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
choiceValueStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

addOption
s_form.addOption('priority' , 'low');

s_form.clearMessages()


This method removes informational messages or error messages in the top of the form.


Return:

TypeDescription
VoidThis method does not return a value.

s_form.clearOptions(fieldName)


This method allows removing all options from the choice list.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

clearOptions
s_form.clearOptions('contact_type');

s_form.clearValue(fieldName)


This method allows removing any value from any field.

It returns TRUE if it is able to clear the value from the field.

It returns FALSE in the following cases:

  • if the column_type is either Boolean or Record Class;
  • if the column_name is equal to 'sys_id';
  • if the column_type is Choice and it does not have a default value.

If the method returns FALSE, then the field. will not be cleared.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
BooleanThis method returns the boolean value (TRUE or FALSE) in the cases described above.


Example:

clearValue
s_form.getValue('sprint') === null ? s_form.clearValue('points') : false;

s_form.getComponent(fieldName)


This method returns the form field by its name.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
SimpleForm objectThis method returns the SimpleForm object containing the form field if the query was successful; otherwise, returns NULL.

Example:

getComponent
const component = s_form.getComponent('name');

s_form.getLabelOf(fieldName)


This method returns the text value of the field label.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
StringThe text of the label.


Example:

getLabelOf
s_form.getLabelOf('assigned_user');

s_form.getSections()


This method allows returning the array of the sections.


Return:

TypeDescription
Array of HTML elementsThe form sections.


s_form.getSectionNames()


This method allows returning the array which will contain the names of all sections, whether visible or not.


Return:

TypeDescription
Array of stringsNames of the sections

s_form.getUniqueValue()


Returns the unique ID (sys_id) of the record displayed on the form.

Return:

TypeDescription
StringReturns the record ID; otherwise, returns NULL.


Example:

getUniqueValue
const sysId = s_form.getUniqueValue();

s_form.getValue(fieldName)


Returns the internal (written down to the database) value of the specified field.

IsDisplayValue parameter was maintained in earlier versions but has been deprecated from version 1.1 and no longer valid. Avoid using it in your scripts. To get a displayed value of a field, use the s_form.getDisplayValue method.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
SimpleRecord Object or Document ID

This method returns the field values in a various types:

  • It returns the database value (that may differ from the displayed value) for the fields of Reference, List, Document ID.
  • And for the other field types, like the String, or Duration, or Big Integer, the method just returns the field value.


Example:

getValue
s_form.getValue('caller_id');

s_form.getDisplayValue(fieldName)


This method returns the displayed value of the field.

Parameter(s):

NameTypeMandatoryDefault value
fieldNameStringYN

Return:

TypeDescription
StringThe displayed value of the specified field.

Example:

getDisplayValue
s_form.getDisplayValue('incident.description');

s_form.hideFieldMsg(input)


This method, as opposed to the s_form.showFieldMsg() method, allows to hide informational or error messages on the specified form field


Parameter(s):

NameTypeMandatoryDefault Value
inputStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

hideFieldMsg
s_form.hideFieldMsg('state');

s_form.hideRelatedLists()


This method allows hiding all related lists on the form.


Return:

TypeDescription
VoidThis method does not return a value.

s_form.hideRelatedList(relListTitle)


This method allows hiding the specified related list on the form.


Parameter(s):

NameTypeMandatoryDefault Value
relListTitleStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

hideRelatedList
s_form.hideRelatedList('Note');

s_form.isNewRecord()


If the record was never saved then this method returns TRUE; otherwise, it returns FALSE.


Return:

TypeDescription
BooleanIf the record was never saved then this method returns TRUE; otherwise, it returns FALSE.


Example:

isNewRecord
s_form.isNewRecord() ? alert('New record') : alert('Not new record');


s_form.isSectionVisible(sectionName)


This method returns TRUE if the section is visible; otherwise, it returns FALSE.


Parameter(s):

NameTypeMandatoryDefault Value
sectionNamestringYN


Return:

TypeDescription
BooleanThis method returns TRUE if the section is visible; otherwise, it returns FALSE.


Example:

isSectionVisible
s_form.isSectionVisible('Notes') ? alert('Visible') : alert('Not visible')'

s_form.removeOption(fieldName, choiceValue)


This method removes the selected option from the list.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
choiceValueStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

removeOption
s_form.removeOption('priority' , 'low');

s_form.save()


This method saves the record without going away (just updating).


Return:

TypeDescription
ObjectThis method returns a promise containing specific data.


s_form.setLabelOf(fieldName, value)


This method sets the text value of the field label.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
valueStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setLabelOf
s_form.setLabelOf('assigned_user', 'Assigned User');

s_form.setSectionMandatory(sectionName, mandatory)


This method allows making the specified section mandatory. Use UI policy instead of this method if possible.


Parameter(s):

NameTypeMandatoryDefault Value
sectionNameStringYN
mandatoryBooleanYN


Return:

TypeDescription
VoidThis method does not return a value


Example:

setSectionMandatory
s_form.isNewRecord() ? s_form.setSectionMandatory('Default' , true) : s_form.setSectionMandatory

s_form.setMandatory(fieldName, mandatory)


This method allows making the specified field mandatory. Use UI policy instead of this method if possible.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
mandatoryBooleanYN


Return:

TypeDescription
VoidThis method does not return a value


Example:

setMandatory
s_form.isNewRecord() ? s_form.setMandatory('subject' , true) : s_form.setMandatory('subject' , false);

s_form.setReadOnly(fieldName, readOnly)


This method allows making the specified field read-only or editable.

Use UI policy instead of this method if possible.

To make a mandatory field read-only, formerly make it non-mandatory using the setMandatory() method.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
readOnlyBooleanYN


Return:

TypeDescription
VoidThis method does not return a value


Example:

setReadOnly
s_form.setReadOnly('priority' , true);

s_form.setSectionDisplay(sectionName, display)


This method allows to show or hide a section.


Parameter(s):

NameTypeMandatoryDefault Value
sectionNameStringYN
displayBooleanYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setSectionDisplay
s_form.setSectionDisplay('Notes' , 'New Notes');

s_form.setValue(fieldName, value)


This method sets the field value.

IsDisplayValue parameter has been maintained in earlier versions but will be deprecated after version 1.1. Avoid using it in your scripts. To set a displayed value of a field, use the s_form.setDisplayValue method.

When setting an empty value (either String type or Array (for the fields of the List type), the field value will be cleared like when using the s_form.clearValue() method.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
valueStringYN
displayValueStringN''


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setValue
s_form.setValue('description', 'my task description', 'Show it');

s_form.setVisible(fieldName, display)


This method allows making a field visible or hidden.

If the fieid is hidden, then the space is left blank. This method cannot hide mandatory field without any value.

Use UI policy instead of this method if possible.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
displayBooleanYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

setVisible
s_form.isNewRecord() ? s_form.setVisible('chronology' , false) : s_form.setVisible('chronology' , true);

s_form.showFieldMsg(fieldName, message, type)


This method displays an informational message or an error message in the specified form field.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
messageStringYN
typeStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

showFieldMsg
s_form.showFieldMsg('subject', 'Cannot be empty', 'info');
s_form.showFieldMsg('subject', 'Cannot be empty', 'warning');
s_form.showFieldMsg('subject', 'Cannot be empty', 'error');

s_form.showRelatedLists()


This method allows displaying all lists related to the form.


Return:

TypeDescription
VoidThis method does not return a value.

s_form.showRelatedList(listTableName)


This method allows displaying the specified lists related to the form.


Parameter(s):

NameTypeMandatoryDefault Value

listTableName

StringYN


Return:

TypeDescription
VoidThis method does not return a value.

Example:

showRelatedList
s_form.showRelatedList('UI Action');

s_form.submit()


This method saves the record with navigating away from the form.


Return:

TypeDescription
VoidThis method does not return a value.

  • No labels