You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 7 Next »
Данный класс включает в себя методы необходимые для настройки форм. Они могут использоваться исключительно на стороне клиента.
Помимо этого, нижеперечисленные методы можно использовать для настройки зависимостей между полями и значениями. Например, для изменения или удаления значений полей .
SimpleForm(table, sys_id)
Используйте этот метод для создания экземпляра объекта SimpleForm.
Параметры:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
table | String | Д | Н |
sys_id | String | Д | Н |
Возврат:
Тип | Описание |
---|---|
Object | Данный метод не возвращает значение. |
Пример:
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(); }
Использование глобальных переменных
Внутри каждой формы записи можно использовать преднастроенные глобальные переменные.
Переменная | Описание |
---|---|
currentFieldLabel | Определяет связь объекта Wrapper с полем. Эта переменная используется с методом getColumnId(), как показано ниже: getColumnId() window.currentFieldLabel.getColumnId() Например, при помощи этой переменной можно вызвать поле контекстного меню. |
currentUiAction |
s_form.addErrorMessage(message)
Используйте этот метод для отображения всплывающего окна с сообщением об ошибке в нижнем правом углу окна.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
message | String | Д | Н |
Возврат:
Тип | Описание |
---|---|
Void | Данный метод не возвращает значение. |
Пример:
s_form.addErrorMessage('Please enter a valid email address using the following format: joe@example.com');
s_form.addInfoMessage(message, durationMilliseconds)
Используйте данный метод для отображения информационного сообщения, которое всплывает в нижнем правом углу окна. Сообщение исчезнет через некоторое количество времени. Укажите это время в милисекундах во втором параметре.
Параметры:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
message | String | Д | Н |
durationMilliseconds | Number | Н | Н |
Возврат:
Тип | Описание |
---|---|
Void | Данный метод не возвращает значение. |
Пример:
s_form.addInfoMessage('Link copied to clipboard', 2000);
s_form.addSuccessMessage(message, durationMilliseconds)
Этот метод отображает сообщение об успешном действии, которое всплывает в нижнем правом углу окна. Сообщение исчезнет через некоторое количество времени. Укажите это время в милисекундах во втором параметре.
Параметры:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
message | String | Д | Н |
durationMilliseconds | Number | Н | Н |
Возврат:
Тип | Описание |
---|---|
Void | Данный метод не возвращает значение. |
Приемр:
s_form.addSuccessMessage('Record was successfully added!', 3000);
s_form.addWarningMessage(message, durationMilliseconds)
Данный метод отображает сообщение с предупреждением в правом нижнем углу окна. Сообщение исчезнет через некоторое количество времени. Укажите это время в милисекундах во втором параметре.
Параметры:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
message | String | Д | Н |
durationMilliseconds | Number | Н | Н |
Возврат:
Тип | Описание |
---|---|
Void | Данный метод не возвращает значение. |
Пример:
s_form.addWarningMessage('This record has been modified by another user', 3000);
s_form.addOption(fieldName, choiceValue)
Используйте данный метод для добавления опции выбора в конец поля со списком выбора, если опция с переданной choiceValue определена для fieldName в текущем наборе опций таблицы.
Это асинхронный метод. Для оптимальной работы системы используйте ключевое слово await как показано в примере ниже.
Параметры:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
fieldName | String | Д | Н |
choiceValue | String | Д | Н |
Возврат:
Тип | Описание |
---|---|
Promise | Этот метод возвращает объект Promise. |
Пример:
const states = ['-1', '0', '2', '5']; s_form.clearOptions('state'); states.forEach(async (stateValue) => { await s_form.addOption('state', stateValue); })
s_form.clearMessages()
Используйте этот метод для того, чтобы закрывать все виды сообщений (информационны и об ошибке) на форме.
Возврат:
Тип | Описание |
---|---|
Void | Данный метод не возвращает значение. |
Пример:
s_i18n.getMessage('End date time cannot be less than start date time', (response) => { s_form.clearMessages(); s_form.addErrorMessage(response); }); return false; // abort form submit
s_form.clearOptions(fieldName)
Используйте данный метод для удаления всех опций из списка с выбором.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
fieldName | String | Д | Н |
Возврат:
Тип | Описание |
---|---|
Void | Данный метод не возвращает значения. |
Пример:
const choices = [ "Phone", "Email", "Self-service" ]; s_form.clearOptions('contact_type'); choices.forEach(async (choiceValue) => { await s_form.addOption('contact_type', choiceValue); });
s_form.clearValue(fieldName)
Используйте данный метод для удаления значения любого поля.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
fieldName | String | Д | Н |
Возврат:
Тип | Описание |
---|---|
Boolean | Метод возвращает false, если очистить поле не получилось, в следующих случаях:
Если метод возвращает true, поле будет очищено. |
Пример:
if (!s_form.getValue('sprint')) { s_form.clearValue('points'); }
s_form.isFieldChanged(fieldName)
Используйте этот метод, чтобы проверить, изменилось ли указанное поле.
Если клиентский скрипт запущен на определенной форме и изменяет ее, данный метод вернет значение true. Изменения могут быть инициированы как скриптом, так и пользователем.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|---|---|---|
fieldName | String | Д | Н |
Возврат:
Тип | Описание |
---|---|
Boolean | Метод возвращает true, если указанное поле было изменено; в противном случае, метод возвращает false. |
Пример:
if (s_form.isFieldChanged('state') && s_form.getValue('state') != 'new') { return false; // abort form submit }
s_form.formId
Этот класс свойств возвращает текущий ID текущего пользователя. Форма представления ID – это ID записи в словаре UI Forms (sys_ui_form).
Возврат:
Тип | Описание |
---|---|
String | Метод возвращает ID записи формы представления в словаре UI Forms (sys_ui_form). |
Пример:
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.getChanges()
Используйте данный метод для получения информации об измененных полях: название поля, предыдущее значение, текущее значение.
Если клиентский скрипт запущен на определенной форме и изменяет ее, метод getChanges() должен включать в себя массив с этими полями. Изменения могут быть инициированы как скриптом, так и пользователем.
Возврат:
Тип | Описание |
---|---|
Array | Данный метод возвращает массив объектов, содержащих информацию об изменении полей. Каждый объект содержит название поля, его предыдущее и текущее значения. |
Пример:
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)
The method returns a label text value.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns a string containing an attribute label value. |
Example:
const FIELD_LABEL = s_form.getLabelOf('username'); s_form.addErrorMessage(`Field "${FIELD_LABEL}" contains invalid characters.`);
s_form.getREMDisplayValue(fieldName)
This method gets a displayable REM attribute value.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns an attribute displayable value. |
Example:
s_form.addErrorMessage(`Service "${s_form.getREMDisplayValue('service')}" is not available`);
s_form.getREMLabelOf(fieldName)
This method gets 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 containing an attribute label value. |
Example:
const FIELD_LABEL = s_form.getREMLabelOf('phone'); s_form.addErrorMessage(`Field "${FIELD_LABEL}" contains invalid characters.`);
s_form.getREMValue(fieldName)
This method gets a REM attribute value.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the database value of the specified field. |
Example:
if (s_form.getREMValue('model')) { s_form.hideFieldMsg('model'); }
s_form.getSections()
Use this method to get an array of sections.
Return:
Type | Description |
---|---|
Array of HTML elements | The form sections. |
s_form.getSectionNames()
Use this method return an array, which contains the names of all sections, visible and hidden.
Return:
Type | Description |
---|---|
Array of strings | This method returns an array containing section names. |
s_form.getTableName()
This method returns a table name that the specified record relates to.
The method returns the system table name, not the table title. Example:
Table name | itsm_incident |
Table title | Incidents |
Return:
Type | Description |
---|---|
String | System table name. |
const TABLE_NAME = s_form.getTableName(); console.log(TABLE_NAME);
s_form.getUniqueValue()
This method returns a unique record ID (sys_id).
Return:
Type | Description |
---|---|
String | This method returns the record ID; otherwise, it returns NULL. |
Example:
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)
This method returns the database value of the specified field.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | This method returns the database value of the specified field. |
Example:
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 method returns the displayed value of the field.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
String | The displayed value of the specified field. |
Example:
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 | Данный метод не возвращает значения. |
Example:
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:
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 informational or error messages in the specified form field.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
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 | Данный метод не возвращает значения. |
Example:
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(s):
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:
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(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
relListTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
if (s_form.getValue('type') == 'external') { s_form.hideRelatedList('Customer'); }
s_form.isNewRecord()
If the record has never been saved, this method returns true; otherwise, it returns false.
Return:
Type | Description |
---|---|
Boolean | If the record has never been saved, this method returns true; otherwise, it returns false. |
Example:
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 the specified field is editable or read-only.
Parameter(s):
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:
if (!s_form.isReadonly('state')) { await s_form.setValue('state', 'new'); }
s_form.isSectionVisible(sectionName)
This method defines if a specified section is visible or not.
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. |
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. |
It makes sense to use this method if the form contains the fields of the Date, Date/Time and Date/Time Specific types, as the method does not support validation checks for the fields of other types.
Example:
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(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | The method returns true if the field is visible; otherwise, it returns false. |
Example:
if (s_form.isVisible('state')) { s_form.setSectionDisplay('Controls', true); }
s_form.refreshUiActions()
This method reloads all UI actions on the form and recalculates the server condition defined for these UI actions without refreshing the page.
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
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 list.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
choiceValue | String | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
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 method saves a record without leaving its form.
Return:
Type | Description |
---|---|
String | This method returns the ID of the saved record. |
Example:
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 method sets 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 | Данный метод не возвращает значения. |
Example:
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 cannot be null.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
mandatory | Boolean | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if its execution has been successful; otherwise, it returns false. This method returns false in the following cases:
|
Example:
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 | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if its execution has been successful; otherwise, it returns false. This method returns false in the following cases:
|
Example:
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 message sets a plain text value of a REM attribute label.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|---|
String | Данный метод не возвращает значения. |
Example:
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.
Parameter(s):
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; otherwise, it returns false. This method returns false in the following cases:
|
Example:
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; otherwise, it returns false. This method returns false in the following cases:
|
Example:
if (s_form.isNewRecord()) { s_form.setREMValue('state', 'new'); s_form.setREMReadOnly('state', true); }
s_form.setREMValue(fieldName, databaseValue)
With this method you can set a value of the REM attribute label.
Note that this method is asynchronous; for better performance, use the await keyword as shown in the code example below.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
databaseValue | Object | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
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.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
display | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
s_form.setREMVisible('additional_info', !s_form.isNewRecord());
s_form.setSectionDisplay(sectionName, display)
Use this method to specify the section you want to hide.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
sectionName | String | Y | N |
display | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
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)
This method sets a field value.
Use s_form.clearValue() method for field clearing 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.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
databaseValue | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method returns a Promise object. |
Example:
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 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.
Hiding a field for which the mandatory attribute is set on a column level (including the mandatory override described in the Column Overriding article) leads to the validation errors after the form is submitted from the client-side.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
fieldName | String | Y | N |
display | Boolean | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
if (!s_form.isNewRecord()) { s_form.setVisible('subject', true); s_form.setVisible('reason', false); }
s_form.showFieldMsg(fieldName, message, type)
Use this method to display a message containing 'info', 'error', or 'warning' value under 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 | Данный метод не возвращает значения. |
Example:
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()
Use this method to display all the lists related to the form.
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
s_form.showRelatedList(listTitle)
Use this method to display specified lists related to the form.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
listTitle | String | Y | N |
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Example:
s_form.showRelatedList('UI Action');
s_form.submit()
With this method you can submitting a record form.
Return:
Type | Description |
---|---|
Void | Данный метод не возвращает значения. |
Deprecated methods
This subsection contains methods that are not recommended to use in application design. They are deprecated as the platform evolves; new methods are developed instead of each of them.
s_form.fieldHasChanges(fieldName)
Use this method to check if the specified field has been changed or not.
This method is deprecated and not recommended to use. Use the s_form.isFieldChanged(fieldName) method instead.
If there is a client script running on the specified form and changing it, the s_form.fieldHasChanges(fieldname) method returns true. Both a user and a script can make changes to the form.
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. |
console.log(s_form.fieldHasChanges('state'));
s_form.hasChanges()
Use this method to get information whether a record form has been changed or not.
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:
if (s_form.hasChanges()) { s_form.save().then(() => s_form.goBack()); } else { s_form.goBack(); }
- No labels