Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The SimpleForm API provides methods for customizing forms.

SimpleForm 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.addErrorMessage(message)

Displays the error message at the top of the form.


Parameter(s):

NameType
MessageString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleaddErrorMessage
s_form.addErrorMessage('Need more information');


s_form.addInfoMessage(message)

Adds an informational message to the top of the form.


Parameter(s):

NameType
messageString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleaddInfoMessage
s_form.addInfoMessage('Record successfully created');


s_form.addOption(fieldName, choiceValue, choiceLabel)

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


Parameter(s):

NameType
fieldNameString
choiceValueString
choiceLabelString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleaddOption
s_form.addOption('priority' , 'low' , 'Low');


s_form.clearMessages()

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 to remove all options from the choice list.


Parameter(s):

NameType
fieldNamestring


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleclearOptions
s_form.clearOptions('contact_type');


s_form.clearValue(fieldName)

This method allows to remove any value from any field.


Parameter(s):

NameType
fieldNameString


Return:

TypeDescription
VoidThis method does not return a value


Example:

Code Block
languagejs
titleclearValue
s_form.getValue('sprint') === null ? s_form.clearValue('points') : false;



s_form.getLabelOf(fieldName)

Returns the text value of the field label


Parameter(s):

NameType
fieldNameString


Return:

TypeDescription
StringThe text of the label.


Example:

Code Block
languagejs
titlegetLabelOf
s_form.getLabelOf('assigned_user');


s_form.getSections()

This method allows to return the array of the sections.


Return:

TypeDescription
Array of HTML elementsThe sections.


s_form.getSectionNames()

This method allows to return 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
Stringsys_id

s_form.getValue(fieldName)

Returns the value of the specified field.


Parameter(s):

NameType
fieldNameString


Return:

TypeDescription
StringThe value of the field.


Example:

Code Block
languagejs
titlegetValue
s_form.getValue('caller_id');


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):

NameType
relListTitleString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlehideRelatedList
s_form.hideRelatedList('Note');


s_form.isNewRecord()

If the record was never saved then returns true; otherwise returns false.


Return:

TypeDescription
BooleanIf the record was never saved then returns true; otherwise returns false.


Example:

Code Block
languagejs
titleisNewRecord
s_form.isNewRecord() ? alert('New record') : alert('Not new record');


s_form.isSectionVisible(sectionName)

Returns true if section is visible; otherwise returns false.


Parameter(s):

NameType
sectionNamestring


Return:

TypeDescription
BooleanReturns true if section is visible; otherwise returns false.


Example:

Code Block
languagejs
titleisSectionVisible
s_form.isSectionVisible('Notes') ? alert('Visible') : alert('Not visible')'


s_form.removeOption(fieldName, choiceValue)

Removes the selected option from the list.


Parameter(s):

NameType
fieldNameString
choiceValueString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleremoveOption
s_form.removeOption('priority' , 'low');


s_form.save()

Saves the record without going away (just updating).


Return:

TypeDescription
VoidThis method does not return a value.


s_form.setLabelOf(fieldName, value)

Sets the text value of the field label


Parameter(s):

NameType
fieldNameString
valueString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlesetLabelOf
s_form.getLabelOf('assigned_user', 'Assigned User');


s_form.setMandatory(fieldName, mandatory)

This method allows making the specified field mandatory.

Use UI policy instead of this method if possible.


Parameter(s):

NameType
fieldNameString
mandatoryBoolean


Return:

TypeDescription
VoidThis method does not return a value


Example:

Code Block
languagejs
titlesetMandatory
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 ‘setMandatory()’ method.


Parameter(s):

NameType
fieldNameString
readOnlyBoolean


Return:

TypeDescription
VoidThis method does not return a value


Example:

Code Block
languagejs
titlesetReadOnly
s_form.setReadOnly('priority' , true);


s_form.setSectionDisplay(sectionName, display)

This method allows to show or hide a section.


Parameter(s):

NameType
sectionNameString
displayBoolean


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlesetSectionDisplay
s_form.setSectionDisplay('Notes' , 'New Notes');


s_form.setValue(fieldName, value, displayValue)

Sets the field value.

For reference fields or list fields, three arguments are in use: ‘value’ is to set a value name and ‘displayValue’ to display in the field.

For fields of the other types, the argument 'value’ uses to display value in the field and set the value name.


Parameter(s):

NameType
fieldNameString
valueString
displayValueString


Return:

TypeDescription
VoidThis method does not return a value.


Examples:

Code Block
languagejs
titlesetValue
s_form.setValue('caller_id' , 2 , 'System Administrator');


Code Block
languagejs
titlesetValue
s_form.setValue('priority' , 'low');


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):

NameType
fieldNameString
displayBoolean


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titlesetVisible
s_form.isNewRecord() ? s_form.setVisible('chronology' , false) : s_form.setVisible('chronology' , true);


s_form.showFieldMsg(fieldName, message, type)

Displays an informational message or an error message in the specified form field.


Parameter(s):

NameType
fieldNameString
messageString
typeString


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
titleshowFieldMsg
s_form.showFieldMsg('subject' , 'Cannot be empty',  'info');


Code Block
languagejs
titleshowFieldMsg
s_form.showFieldMsg('subject' , 'Cannot be empty',  'warning');


Code Block
languagejs
titleshowFieldMsg
s_form.showFieldMsg('subject' , 'Cannot be empty',  'error');


s_form.showRelatedLists()

This method allows to display all lists related to the form.


Return:

TypeDescription
VoidThis method does not return a value.


s_form.showRelatedLists(relListTitle)

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


Parameter(s):

NameType
relListTitleString


Return:

TypeDescription
VoidThis method does not return a value.


s_form.submit()

Saves the record with navigating away from the form.


Return:

TypeDescription
VoidThis method does not return a value.


Table of Contents
absoluteUrltrue
classfixedPosition