Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This class provides methods for forms configurations. These methods can only be used on the client side.
You can also use these methods to configure the dependencies between the fields and the values. For , for example, changing the values of the fields or clearing the fields.
SimpleForm(table, sys_id)
This constructor instantiates Use this constructor to instantiate a new SimpleForm object.
Parameters:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
table | String | Y | N |
sys_id | String | Y | N |
Return:
Type | Description |
---|---|
Object | This method returns a form object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
window.s_widget_custom.submit = async function () { await s_widget.serverUpdate(); const tableName = s_widget.getFieldValue('table_name'); const recordId = s_widget.getFieldValue('record_id'); const builtInForm = new SimpleForm(tableName, recordId); await builtInForm.save().then(s_form.save()); s_modal.setShow(false); s_go.reloadWindow(); } |
Global variable usage
Within any record form, you can use predefined global variables.
Description
Defines a link to a Wrapper object for a field. The variable is used with the getColumnId() method.
See the example:
Code Block |
---|
window.currentFieldLabel.getColumnId() |
One of the usage cases of this variable is the field context menu call.
Image Removed
modalForm()
Use this object of the SimpleForm class to interact with the modal window of the opened record from the client script of the form. The form is available by using the <Form> tag in the modal window widget.
Access the object using s_form.modalForm.
Returns:
Type | Description |
---|---|
Object | This method returns the form object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.modalForm.setValue('state', '2') |
Global variable usage
Within any record form, you can use predefined global variables.
Variable | Description | ||
---|---|---|---|
currentFieldLabel | Defines a link to a Wrapper object for a field. The variable is used with the getColumnId() method.
One of the usage cases of this variable is the field context menu call. | ||
currentUiAction |
s_form.addErrorMessage(message)
Use this method to display an error toast message in the lower right corner.
Parameter
s_form.addErrorMessage(message)
Use this method to display an error toast message in the bottom right corner.
Parameter:
Return:
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.addErrorMessage('Please enter a valid email address using the following format: joe@example.com'); |
s_form.addInfoMessage(message, durationMilliseconds)
This method displays an informational toast message in the bottom right corner. The message disappears after a certain period of time. In the second parameter, specify this period in milliseconds.
Parameters:
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.addInfoMessageaddErrorMessage('Link copied to clipboard', 2000Please enter a valid email address using the following format: joe@example.com'); |
s_form.
addSuccessMessageaddInfoMessage(message, durationMilliseconds)
This method displays a message about a successul action in the bottom Use this method to display an informational toast message in the lower right corner. The message disappears after a certain period of time. Specify this period in milliseconds in the second parameter.In the durationMilliseconds parameter, specify this period in milliseconds.
ParametersParameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
message | String | Y | N |
durationMilliseconds | Number | N | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.addSuccessMessageaddInfoMessage('RecordLink wascopied successfullyto added!clipboard', 30002000); |
s_form.
addWarningMessageaddSuccessMessage(message, durationMilliseconds)
This Use this method displays to display a warning message about a successul action in the bottom lower right corner. The message disappears after a certain period of time. Specify this period in period in milliseconds in the second durationMilliseconds parameter.
ParametersParameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
message | String | Y | N |
durationMilliseconds | Number | N | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.addWarningMessageaddSuccessMessage('ThisRecord recordwas has been modified by another usersuccessfully added!', 3000); |
s_form.
addOptionaddWarningMessage(
fieldNamemessage,
choiceValuedurationMilliseconds)
This Use this method adds a choice option to the end of the choice field. A user can add a choiceValue values defined for fieldName into the current set of the table options.
to display a warning message in the lower right corner. The message disappears after a certain period of time. Specify this period in milliseconds in the durationMilliseconds parameter.
Parameters:
Name | Type | Mandatory | Default |
---|
value |
---|
message | String | Y | N |
durationMilliseconds |
Number |
N | N |
Return:
Type | Description |
---|
Void | This method |
does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const choices = ['10', '20', '30']; s_form.clearOptions('contact_type'); for (const optionValue of choices) { await s_form.addOption('contact_type', optionValue); }s_form.addWarningMessage('This record has been modified by another user', 3000); |
s_form.
clearMessagesaddOption(fieldName, choiceValue)
Use this method to close all kinds of messages (both informational and error) in the form.to add a choice option to the end of the choice field. A user can add a choiceValue values defined for fieldName into the current set of the table options.
Note |
---|
This method is asynchronous; for better performance, use the await keyword as shown in the code example below. |
Parameters:
Name | Type | Mandatory | Default value |
---|---|---|---|
fieldName | String | Y | N |
choiceValue | String | Y | N |
Return:
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_i18n.getMessage('End date time cannot be less than start date time', (response) => { const choices = ['10', '20', '30']; s_form.clearMessagesclearOptions('contact_type'); for (const optionValue of choices) { await s_form.addErrorMessage(responseaddOption('contact_type', optionValue); }); return false; // abort form submit |
s_form.
clearOptionsclearMessages(
fieldName)
Use this method to remove all options from the choice list.
Parameter:
close all kinds of messages (both informational and error) in the form.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const choices = ['10', '20', '30']; s_i18n.getMessage('End date time cannot be less than start date time', (response) => { s_form.clearOptionsclearMessages('contact_type'); for (const optionValue of choices) { await s_form.addOption('contact_type', optionValueaddErrorMessage(response); }); |
s_form.
clearValueclearOptions(fieldName)
anchorUse this method to clear out any field, i.e., delete its valueremove all options from the choice list.
Parameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|
It returns false if it is unable to clear the value of the field 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.
Otherwise, the method returns true.
Void | This method does not return a value. |
ExampleExample:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (!const choices = ['10', '20', '30']; s_form.getValueclearOptions('sprintcontact_type'); for (const optionValue of choices) { await s_form.clearValueaddOption('points'contact_type', optionValue); } |
s_form.
isFieldChangedclearValue(fieldName) Anchor s_form.clearValue s_form.clearValue
s_form.clearValue | |
s_form.clearValue |
If there is a client script running on the specified form and changing it, this method returns true. Both a user and a script can initiate the changes.
Use this method to verify if the specified field has been changed or not.
clear out any field, that is delete its value.
Parameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns |
false if it is unable to clear the value of the field in the following cases:
Otherwise, the method returns true. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (!s_form.isFieldChangedgetValue('statesprint')) &&{ s_form.getValueclearValue('state') != 'new') { return false; // abort form submitpoints'); } |
s_form.
formIdisFieldChanged(fieldName)
Use this method to verify whether the specified field has been changed.
Info |
---|
If there is a client script changing the specified field is running on the form, this method returns true. Both a user and a script can initiate the changes. |
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if the specified field has been changed; otherwise, it returns false |
This class property returns the current form ID. The form view ID is an ID of the record in the UI Forms (sys_ui_form) dictionary.
Return:
Type | Description |
---|---|
String | This method returns the record ID of the form view in the UI Forms (sys_ui_form) dictionary. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const url = new URL(`${API_BASE_URL}/export/excel`); if (typeofif (s_form.isFieldChanged('state') && s_form.getValue('state') !== "undefined" 'new') { return false; // abort url.searchParams.set('form_id', s_form.formId); } window.open(url, "_blank"); submit } |
s_form.
getAllFields()formId
Use this
method to get a list of fields with their values placed on the form.class property to return the current form ID. The form view ID is an ID of the record in the UI Forms (sys_ui_form) table.
Return:
Type | Description |
---|---|
String | This method returns the record ID of the form view in the UI Forms (sys_ui_form) table. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const url = new URL(`${API_BASE_URL}/export/excel`);
if (typeof s_form !== "undefined") {
url.searchParams.set('form_id', s_form.formId);
}
window.open(url, "_blank"); |
s_form.getAllFields()
Use this method to get a list of fields with their values placed on the form.
The return value contains two keys:
- thedata key is an object, where the keys are the system field names, and the values are the values of those fields.
- the error key is an array with error messages if the form is saved in the current state.
Parameter:
Name | Type | Mandatory | Default value |
---|---|---|---|
isAll | Boolean | N | false |
Return:
Type | Description |
---|---|
Object | When the isAll parameter is set to false, this method returns the info about the fields, where the values have been changed. When the value is set to true, the method returns the information about the fields on the form from all the sections, including the ones hidden by client scripts. On the new record form, the method returns a list of all form fields regardless of the isAll value. |
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
if (!s_form.getAllFields(true).data.hasOwnProperty('state')) return; |
s_form.getChanges()
Use this method to retrieve information about the changed fields: field name, previous value, current value.
Info |
---|
If there is a client script changing some fields is running on this form, the getChanges() method includes such fields in the array. Both a user and a script can initiate the changes. |
Return:
Type | Description |
---|---|
Array of Objects | This method returns an array of objects with the fields changes. Each object contains a field name, its previous and current values. |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isChanged()) {
const changedFields = s_form.getChanges();
let payload = {};
changedFields.forEach((field) => {
payload[field.fieldName] = field.currentValue;
});
SimpleStorage.setItem('payload', payload);
} |
s_form.getLabelOf(fieldName)
Use this method to return a label text value.
Parameter(s)
The return value contains two keys: data and error. The data key is an object, where the keys are the system field names, and the values are the values of those fields. The error key is an array with error messages if the form is saved in the current state.
Parameter:
Name | Type | Mandatory | Default |
---|
value |
---|
fieldName |
Return:
String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns a string that contains a displayed field name |
Type | Description |
Object | . |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (!const FIELD_LABEL = s_form.getLabelOf('username'); s_form.getAllFields(true).data.hasOwnProperty('state')) returnaddErrorMessage(`Field "${FIELD_LABEL}" contains invalid characters.`); |
s_form.
getChangesgetREMDisplayValue(fieldName)
This Use this method is used to retrieve information about the changed fields: field name, previous value, current value.
to get a displayable REM attribute value.
Find the values represented in the client scripts according to the field types in the table.
Parameter:
Name | Type | Mandatory | Default value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description | |||
---|---|---|---|---|
String | This method returns | an arraya value of | objects withthe | fields changes. Each object contains a field name, its previous and current values.displayable attribute. |
Example:
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
s_form.addErrorMessage(`Service "${s_form.getREMDisplayValue('service')}" is not available`);if (s_form.isChanged()) { const changedFields = s_form.getChanges(); let payload = {}; changedFields.forEach((field) => { payload[field.fieldName] = field.currentValue; }); SimpleStorage.setItem('payload', payload); } |
s_form.
getLabelOfgetREMLabelOf(fieldName)
The Use this method returns to get a label text value of a REM attribute.
Parameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns a string |
that contains an attribute label value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const FIELD_LABEL = s_form.getLabelOfgetREMLabelOf('usernamephone'); s_form.addErrorMessage(`Field "${FIELD_LABEL}" contains invalid characters.`); |
s_form.
getREMDisplayValuegetREMValue(fieldName)
This Use this method gets to get a displayable REM attribute attribute value.
Find the values represented in the client scripts according to the field types in the table.
Parameter:
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns an the database value of the displayable attributespecified field. |
Example:
Code Block | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
if (s_form.addErrorMessage(`Service "${s_form.getREMDisplayValuegetREMValue('servicemodel'))}" is{ not available`);s_form. |
hideFieldMsg( |
This method gets a label text value of a REM attribute.
Parameter(s):
Name
Type
Mandatory
Default Value
'model');
} |
s_form.getSections()
Use this method to get an array of sections.
Return:
Type | Description | String|
---|---|---|
Array of HTML elements | This method returns | a string containing an attribute label valuean array that conatains sections of a form. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const FIELD_LABELsectionNames = s_form.getSections().getREMLabelOf('phone'); map(section => section.name); if (sectionNames.length) { s_form.addErrorMessageaddInfoMessage(`Field "${FIELD_LABEL}" contains invalid characters.`);`You can move between ${sectionNames.join(', ')}` sections); } |
s_form.
getREMValuegetSectionNames(
fieldName)
This method gets a REM attribute value.
Parameter:
Name
Type
Mandatory
Default Value
Use this method return an array that contains the names of all sections, visible and hidden.
Return:
Type | Description | String|
---|---|---|
Array of Strings | This method returns | the database value of the specified fieldan array that contains section names. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
ifconst sectionNames = (s_form.getREMValuegetSectionNames('model')) if (sectionNames.length) { s_form.hideFieldMsg('model'); } |
s_form.getSections()
Use this method to get an array of sections.
Return:
s_form.getSectionNames()
Use this method return an array, which contains the names of all sections, visible and hidden.
Return:
addInfoMessage(`You can move between ${sectionNames.join(', ')}` sections);
} |
s_form.getTableName()
This Use this method returns to return a table name that the specified record relates to.
Note | ||||
---|---|---|---|---|
The method returns the system table name, not the table title. Example:
|
Return:
Type | Description |
---|---|
String | System This method returns the system table name. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const TABLE_NAME = s_form.getTableName(); console.log(TABLE_NAME); |
s_form.getUniqueValue()
This Use this method returns to return a unique record ID (sys_id).
Return:
Type | Description |
---|---|
String | This method returns the record ID; otherwise, it returns |
null. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const TABLE_NAME = s_form.getTableName(); const RECORD_ID = s_form.getUniqueValue(); const currentRecord = new SimpleRecord(TABLE_NAME); currentRecord.get(RECORD_ID, ()=> { if (currentRecord.sys_id === RECORD_ID) { s_form.addInfoMessage(currentRecord.sys_created_at); } }); |
s_form.getValue(fieldName)
Use this method to return the database value of the specified field .
Find the values represented in the client scripts according to the field types in the tableThis method returns the database value of the specified field.
Parameter:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the database value of the specified field. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const callerId = s_form.getValue('caller_id'); if (!callerId) { const callerRecord = new SimpleRecord('employee'); callerRecord.get(callerId, ()=> { if (callerRecord.sys_id && callerRecord.personal_schedule) { await s_form.setValue('schedule', callerRecord.personal_schedule); } else { s_form.addInfoMessage('Users schedule is not defined'); } }); } |
s_form.getDisplayValue(fieldName)
This Use this method returns to return the displayed value of the field.
Find the values represented in the client scripts according to the field types in the table.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String |
This method returns the displayed value of the specified field. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.addInfoMessage(`Service "${s_form.getDisplayValue('service')}" is not available`); |
s_form.goBack()
Use this method to perform a redirection to the previous page. If it is not possible, the redirection leads to the list view of the current instance, for example, to a list of incidents from an incident record.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isChanged()) { s_form.save().then(() => s_form.goBack()); } else { s_form.goBack(); } |
s_form.isChanged()
Use this method to get information whether a record form has been changed.
Return:
Type | Description |
---|---|
Boolean | The method returns true if any changes have been made on the record form; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isChanged()) { s_form.save().then(() => s_form.goBack()); } else { s_form.goBack(); } |
s_form.hideFieldMsg(fieldName)
This method, unlike the s_form.showFieldMsg() method, hides Use this method to hide informational or error messages in the specified form 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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getValue('state')) { s_form.hideFieldMsg('state'); } |
s_form.hideRelatedLists()
Use this method to hide all related lists on the form.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getValue('type') == 'internal') { s_form.hideRelatedLists(); } |
s_form.isMandatory(fieldName)
Use this method to check if the specified field is mandatory.
Parameter:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if the field is mandatory; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isMandatory('state') && !s_form.getValue('state')) { s_form.addInfoMessage('State cannot be None'); } |
s_form.hideRelatedList(relListTitle)
Use this method to specify a related list you need to hide.
Parameter:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
relListTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getValue('type') == 'external') { s_form.hideRelatedList('Customer'); } |
s_form.isNewRecord()
Use Use this method to find out if the record is new.
Return:
Type | Description |
---|---|
Boolean | If the record has never been saved, this method returns true; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isNewRecord()) { await s_form.setValue('state', 'new'); s_form.setReadOnly('state', true); } |
s_form.isReadonly(fieldName)
Use this method to check if verify whether a user can edit the specified field is via the interface editable or the field is read-only.
Parameter:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if the field is read-only; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (!s_form.isReadonly('state')) { await s_form.setValue('state', 'new'); } |
s_form.isSectionVisible(sectionName)
This Use this method defines to define if a specified section is visible or not.
Parameter:
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isSectionVisible('Instructions')) { s_form.addInfoMessage('Check out the "Instructions" section', 5000); } |
s_form.isValid()
Use this method to check if the specified form is valid or not.
Return:
Type | Description |
---|---|
Boolean | This method returns true if the form is valid; otherwise, returns false. |
Note |
---|
It makes sense to use this method if the form contains the fields of the Date, Date /Time and Date/ Time Specific typescolumns, as the method does not support validation checks for the fields of other types. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (!s_form.isValid()) { s_form.addErrorMessage('This form is invalid'); } |
s_form.isVisible(fieldName)
Use this method to check if the specified field is visible or not.
Parameter:
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | The method returns true if the field is visible; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isVisible('state')) { s_form.setSectionDisplay('Controls', true); } |
s_form.refreshUiActions()
This Use this method reloads to reload all UI actions on on the form and recalculates the server condition reverifies conditions to display a button that are defined for these UI actions without refreshing the page.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const stateValue = s_form.getValue('state'); if (stateValue == 'in-progress') { s_form.refreshUiActions(); } |
s_form.removeOption(fieldName, choiceValue)
Use this method to specify and delete an option from the choice list.
Parameters:
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const serviceId = s_form.getValue('service'); if (serviceId) { const service = new SimpleRecord('sys_cmdb_ci_service'); service.get(serviceId, ()=> { if (service.business_criticality > '1') { s_form.removeOption('impact', 'low'); s_form.removeOption('urgency', 'low'); } }); } |
s_form.save()
This Use this method saves to save a record without leaving its form.
Return:
Type | Description |
---|---|
String | This method returns the ID of the saved record. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const sysId = await s_form.save().finally(__resolveServerResponse); await s_user.setPreference(preferenceApplicationName, packApplicationId); await s_user.setPreference(preferenceLocalPackName, sysId); await s_pref.refresh(); |
s_form.setLabelOf(fieldName, value)
This Use this method sets to set a 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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getTableName() == "employee") { s_form.setLabelOf("email", "Personal Email"); s_form.setLabelOf("manager.email", "Manager's Email"); } else { s_form.setLabelOf("email", "Email"); } |
s_form.setMandatory(fieldName, mandatory)
Use this method to change a specified field to a mandatory field, i.e., it that is it cannot be null.
Parameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
mandatory | Boolean | N | true |
Return:
Type | Description |
---|---|
Boolean | This method returns true if its execution has been successful |
. |
It returns false in the following cases:
|
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const scriptType = s_form.getValue('type'); const mandatoryColumn = ['onChange', 'onCellEdit'].includes(scriptType); s_form.setVisible('column_id', mandatoryColumn); s_form.setMandatory('column_id', mandatoryColumn); |
s_form.setReadOnly(fieldName, readOnly)
Use this method to change a specified field to read-only or editable.
Parameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
readOnly | Boolean | N | true |
Return:
Type | Description |
---|---|
Boolean | This method returns true if its execution has been successful |
. |
It returns false in the following cases:
|
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getValue('any_tables')){ s_form.setMandatory('table_id', false); s_form.setReadOnly('table_id', true); s_form.setVisible('table_id', false); } |
s_form.setREMLabelOf(fieldName, value)
This method sets Use this method to set a plain text value of a REM attribute label.
Parameter(s):
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
fieldName | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the set value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getTableName() == 'user') { s_form.setREMLabelOf('email', 'Email'); } else { s_form.setREMLabelOf('email', 'Personal Email'); } |
s_form.setREMMandatory(fieldName, mandatory)
Use this method to make a field specified by a REM attribute mandatory.
Parameters:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
mandatory | Boolean | Y | true |
Return:
Type | Description |
---|---|
Boolean | This method returns true if its execution has been successful |
. |
It returns falsein the following cases:
|
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
const isDeliveryFilled = !!s_form.getValue('delivery'); s_form.setREMMandatory('phone', isDeliveryFilled); |
s_form.setREMReadOnly(fieldName, readOnly)
Use this method to make a field specified by a REM attribute read-only.
Parameter(s):
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
readOnly | Boolean | Y | true |
Return:
Type | Description |
---|---|
Boolean | This method returns true if its execution has been successful |
. |
It returns false in the following cases:
|
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.isNewRecord()) { s_form.setREMValue('state', 'new'); s_form.setREMReadOnly('state', true); } |
s_form.setREMValue(fieldName, databaseValue)
With Use this method you can to set a value of the REM attribute label.
Note |
---|
Note that this method is asynchronous; for better performance, use the await keyword as shown in the code example below. |
Parameters:
Name | Type | Mandatory | Default Valuevalue |
---|---|---|---|
fieldName | String | Y | N |
databaseValue | Any | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
await s_form.setREMValue('state', 'new'); s_form.save(); |
s_form.setREMVisible(fieldName, display)
Use this method to define visibility of the field specified by a REM attribute.
Parameters:
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.setREMVisible('additional_info', !s_form.isNewRecord()); |
s_form.setSectionDisplay(sectionName, display)
Use this method to specify the section you need to display.
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.getValue('state') == '7') { // Completed s_form.setSectionDisplay('Closure Information', true); s_form.setMandatory('closure_code', true); s_form.setMandatory('closure_notes', true); } else { s_form.setMandatory('closure_code', false); s_form.setMandatory('closure_notes', false); s_form.setSectionDisplay('Closure Information', false); } |
s_form.setValue(fieldName, databaseValue)
Use this method to set a field value.
Note |
---|
Use s_form.clearValue() method for field clearing instead to clear the field instead of setting an empty string value. Note that this method is asynchronous; for better performance, use the await keyword as shown in the code example below. |
Parameters:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
databaseValue | String | Y | N |
Return:
Type | Description |
---|---|
Object | This method returns a Promise object. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
await s_form.setValue('state', '7'); // Completed await s_form.setValue('closure_notes', articleBodies.join('\n')); await s_form.setValue('closure_code', '1'); // Solved 1st Level s_form.save() .then(() => { s_i18n.getMessage(`The typical solution is applied`, (e) => { s_form.addInfoMessage(e); }) }); |
s_form.setVisible(fieldName, display)
Use this method to manage displaying of the display of the fields that have been added to the form through the Form Layout. You can hide or show the fields. The hidden field state is similar to being removed from the form view.
Note |
---|
Hiding a field for which the mandatory attribute is set on a column level (including the mandatory override described in the Column Override article) leads to the validation errors after the form is saved or submitted from the client-side. |
Parameters:
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (!s_form.isNewRecord()) { s_form.setVisible('subject', true); s_form.setVisible('reason', false); } |
s_form.showFieldMsg(fieldName, message, type) Anchor fieldmsg fieldmsg
fieldmsg | |
fieldmsg |
Use this method to display informantional and warning messages, and messages containing error description under the specified form field.
Parameters:
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 | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.showFieldMsg('subject', 'Cannot be empty', 'error'); |
s_form.showRelatedLists()
Use this method to display all the lists related to the form.Return:
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.showRelatedLists(); |
s_form.showRelatedList(listTitle)
Use this method to display a specified list related to the form.
Parameter:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
listTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.showRelatedList('UI Action'); |
s_form.submit()
Use this method to submit a record form.
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
s_form.submit(); |
Deprecated methods
s_form.fieldHasChanges(fieldName)
Use this method to check if This method checks whether the specified field has been changed or not.
Warning |
---|
This method is deprecated and not recommended to use. Use the s_form.isFieldChanged(fieldName) method instead. |
Info |
---|
If there is a client script running on the specified form and changing itchanging a scpecified fieldon the form is running, the s_form. fieldHasChanges(fieldname) method returns true. Both a user and a script can make changes to the form. |
Parameter:
Name | Type | Mandatory | Default |
---|
value | |||
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if the specified field has been changed; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
console.log(s_form.fieldHasChanges('state')); |
s_form.hasChanges()
Use this method to get This method gets t information whether a record form has been changed or not.
Warning |
---|
This method is deprecated and not recommended to use. Use the s_form.isChanged() method instead. |
Return:
Type | Description |
---|---|
Boolean | The method returns true if any changes were made on the record form; otherwise, it returns false. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
if (s_form.hasChanges()) { s_form.save().then(() => s_form.goBack()); } else { s_form.goBack(); } |
Table of Contents | ||
---|---|---|
|