Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
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.addErrorMessage(message)
This method displays the error message at the top of the form.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
Message | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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 should be specified by $duration parameter.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
message | String | Y | N |
duration | Number | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.addInfoMessage('Record successfully created'); |
s_form.addOption(fieldName, choiceValue, choiceLabel)
This method adds a choice option to the end of the choice list field.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
choiceValue | String | Y | N |
choiceLabel | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.addOption('priority' , 'low' , 'Low'); |
s_form.clearMessages()
This method removes informational messages or error messages in the top of the form.
Return:
Type | Description |
---|---|
Void | This method does not return a value |
s_form.clearOptions(fieldName)
This method allows removing all options from the choice list.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.clearOptions('contact_type'); |
s_form.clearValue(fieldName)
This method allows removing any value from any field.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.getValue('sprint') === null ? s_form.clearValue('points') : false; |
s_form.getLabelOf(fieldName)
This method returns the text value of the field label.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | The text of the label. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.getLabelOf('assigned_user'); |
s_form.getSections()
This method allows returning the array of the sections.
Return:
Type | Description |
---|---|
Array of HTML elements | The sections. |
s_form.getSectionNames()
This method allows returning the array which will contain the names of all sections, whether visible or not.
Return:
Type | Description |
---|---|
Array of strings | Names of the sections |
s_form.getUniqueValue()
Returns the unique ID (sys_id) of the record displayed on the form.
Return:
Type | Description |
---|---|
String | sys_id |
s_form.getValue(fieldName)
Returns the value of the specified field.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | The value of the field. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.getValue('caller_id'); |
s_form.hideRelatedLists()
This method allows hiding all related lists on the form.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
s_form.hideRelatedList(relListTitle)
This method allows hiding the specified related list on the form.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
relListTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.hideRelatedList('Note'); |
s_form.isNewRecord()
If the record was never saved then this method returns TRUE; otherwise, it returns FALSE.
Return:
Type | Description |
---|---|
Boolean | If the record was never saved then this method returns TRUE; otherwise, it returns FALSE. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
sectionName | string | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns TRUE if the section is visible; otherwise, it returns FALSE. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
choiceValue | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.removeOption('priority' , 'low'); |
s_form.save()
This method saves the record without going away (just updating).
Return:
Type | Description |
---|---|
Object | This method returns a promise containing specific data. |
s_form.setLabelOf(fieldName, value)
This method sets the text value of the field label.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
mandatory | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
readOnly | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
s_form.setReadOnly('priority' , true); |
s_form.setSectionDisplay(sectionName, display)
This method allows to show or hide a section.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
sectionName | String | Y | N |
display | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.setSectionDisplay('Notes' , 'New Notes'); |
s_form.setValue(fieldName, value, displayValue)
This method sets the field value.
For reference fields or list fields, three arguments are in use: the value argument sets as a value name and the displayValue argument displays in the field.
For fields of the other types, the value argument uses to display value in the field and sets the value name.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
value | String | Y | N |
displayValue | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Examples:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.setValue('caller_id' , 2 , 'System Administrator'); |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
display | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
message | String | Y | N |
type | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.showFieldMsg('subject' , 'Cannot be empty', 'info'); |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.showFieldMsg('subject' , 'Cannot be empty', 'warning'); |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
getLabelOfss_form.showFieldMsg('subject' , 'Cannot be empty', 'error'); |
s_form.showRelatedLists()
This method allows displaying all lists related to the form.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
s_form.showRelatedList(relListTitle)
This method allows displaying the specified lists related to the form.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
relListTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
s_form.submit()
This method saves the record with navigating away from the form.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Table of Contents | ||||
---|---|---|---|---|
|