Versions Compared

Key

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

This class provides methods to configure 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.

SimpleForm(table, sys_id)


Instantiates a new SimpleForm object.

NameTypeMandatoryDefault Value
tableStringYN
sys_idStringYN


Code Block
languagejs
themeEclipse
titleSimpleForm
linenumberstrue
const formObject = new SimpleForm(s_form.table, s_form.sysId);


Return:

TypeDescription
ObjectThis method returns a form object.

s_form.addErrorMessage(message)


This method displays the error toast message in the bottom right corner.


Parameter(s):

NameTypeMandatoryDefault Value
messageStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

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

s_form.addInfoMessage(message, durationMilliseconds)


This method displays an informational toast message in the bottom right corner. The message is expirable, its expire period (in milliseconds) should be specified by second parameter.


Parameter(s):

NameTypeMandatoryDefault Value
messageStringYN
durationMillisecondsNumberYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddInfoMessage
linenumberstrue
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 (if option with passed choiceValue defined for fieldName for current table options set).

Note

Please note that this method is asynchronous; for better performing, use the await keyword like shown in the code example below.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
choiceValueStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleaddOption
linenumberstrue
const states = ['-1', '0', '2', '5'];
s_form.clearOptions('state');
states.forEach(stateValue => {
    await s_form.addOption('state', stateValue);
}

s_form.clearMessages()


This method is used to close all kinds of messages (both informational and error) in the form.


Return:

TypeDescription
VoidThis method does not return a value.


Code Block
languagejs
themeEclipse
titleclearMessages()
linenumberstrue
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)


Using this method, you can remove all options from the choice list.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleclearOptions
linenumberstrue
const choices =
  {
    "Phone": "10",
    "Email": "20",
    "Self-service": "30"
  };
const choicesArray = Object.keys(choices);
s_form.clearOptions('contact_type');
choicesArray.forEach((choiceValue) => {
  s_form.addOption('contact_type', choices[choiceValue]);
});

s_form.clearValue(fieldName)


This method is used to clear out any field, i.e., delete its value.

Using this method you can select a value and remove it from the field.

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

It returns FALSE'true' 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'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:

Code Block
languagejs
themeEclipse
titleclearValue
linenumberstrue
if (!s_form.getValue('sprint')) {
  s_form.clearValue('points');
}


s_form.

formId

This class property returns the current form ID for the current user. The form view ID is an ID of the record in the UI Forms (sys_ui_form) dictionary.

Return:

Type

Description

StringReturns the record form view ID (ID of the record in the UI Forms (sys_ui_form) dictionary).

fieldHasChanges(fieldName)


This method is used to define if the specified field has been changed or not.

Info

If there is a client script running on the specified form and changing it, the fieldHasChanges method will return 'true'. That is, it is not necessary that the change is made by a user, the form can be changed by a script.

Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN

Return:

TypeDescription
Boolean

This method returns 'true' if the field sent by the parameter has been changed; otherwise returns 'false'.

Example:

Code Block
languagejs
themeEclipse
titles_form.fieldHasChanges
linenumberstrue
if (s_form.fieldHasChanges('state') && s_form.getValue('state') != 'new') {
    return false;
}


s_form.formId


This class property returns the current form ID for the current user. The form view ID is an ID of the record in the UI Forms (sys_ui_form) dictionary.

Example:

Code Block
languagejs
themeEclipse
titleformId
linenumberstrue
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.getLabelOf(fieldName)

The method returns the label text value.

Parameter(s):

NameTypeMandatoryDefault ValuefieldNameStringYN

Return:

Type

Description

String
The label text
Returns the record form view ID (ID of the record in the UI Forms (sys_ui_form) dictionary).


Example:

Code Block
languagejs
themeEclipse
titlegetLabelOfformId
linenumberstrue
if (s_form.getValue('name').match(/[\/|_*]/g)) {
  s_form.addErrorMessage(`Field "${s_form.getLabelOf('name')}" contains invalid characters.`);
}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.

getREMDisplayValue

getChanges(

fieldName

)


This method gets the displayable REM attribute value.

Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN

is used to retrieve information about changed fields: titles, previous value, current value.

Info

If there is a client script running on this form and changing it, the getChanges() method will include such fields in the array. That is, it is not necessary that the change is made by a user, it can be done by a script.

Return:

TypeDescription
ArrayThis method returns an array of changed fields (titles), including their previous value and the current value.

Return:

Type

Description

StringMethod returns attribute displayable value.

Example:

Code Block
languagejs
themeEclipse
titlegetREMDisplayValues_form.getChanges
linenumberstrue
if (addInfoMessage(`Service "${s_form.getREMDisplayValuehasChanges('service')}" is not available`);)) {
    const changedFields = s_form.
getREMLabelOf(fieldName)

This message gets the plain text value of the REM attribute label.

Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN
getChanges();
    let payload = {};
    changedFields.forEach((field) => {
      payload[field.fieldName] = field.currentValue;
    });
    SimpleStorage.setItem('payload', payload);
}


s_form.getLabelOf(fieldName)


The method returns the label text value.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN


Return:

TypeDescription
StringThe label text.


Example:

Code Block
languagejs
themeEclipse
titlegetLabelOf
linenumberstrue
if (s_form.getValue('name').match(/[\/|_*]/g)) {
  s_form.addErrorMessage(`Field "${s_form.getLabelOf('name')}" contains invalid characters.`);
}

s_form.getREMDisplayValue(fieldName)


This method gets the displayable REM attribute value.


Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN

Return:

Type

Description

StringMethod returns attribute displayable value.

Example:

Code Block
languagejs
themeEclipse
titlegetREMDisplayValue
s_form.addErrorMessage(`Service "${s_form.getREMDisplayValue('service')}" is not available`);


s_form.getREMLabelOf(fieldName)


This message gets the plain text value of the REM attribute label.


Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN

Return:

Type

Description

StringThis method returns string containing attribute label value.

Example:

Code Block
languagejs
themeEclipse
titlegetREMLabelOf
linenumberstrue
if (!!s_form.getValue('phone').match(/[^\+\s\d\(\)\-]/g)) {
    s_form.addErrorMessage(`Field "${s_form.getREMLabelOf('phone')}" contains invalid characters.`);
}

s_form.getREMValue(fieldName)


This method gets the REM attribute value.

Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN

Return:

Type

Description

StringThis method returns the current attribute value.

Example:

Code Block
languagejs
themeEclipse
titlegetREMValue
linenumberstrue
if (!!s_form.getREMValue('model')) {
    s_form.hideFieldMsg('model');
}

s_form.getSections()


Using this method, you can get an array of sections.


Return:

TypeDescription
Array of HTML elementsThe form sections.

s_form.getSectionNames()


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


Return:

TypeDescription
Array of stringsThis method returns array containing section names.

s_form.getTableName()


This method returns the table name to which the specified record relates.

Note

The method returns system table name, not the table title. Example:

Table nameitsm_incident
Table titleIncidents


Return:

TypeDescription
StringSystem table name.


Example:
Code Block
languagejs
themeEclipse
titlegetTableName
linenumberstrue
if (['article', 'model'].includes(s_form.getTableName())) {
    s_form.setSectionMandatory('Review', true);
} else {
    s_form.setSectionMandatory('Review', false);
}

s_form.getUniqueValue()


This method returns the unique record ID (sys_id).

Return:

TypeDescription
String
This method returns string containing attribute label value
Returns the record ID; otherwise, returns NULL.


Example:

Code Block
languagejs
themeEclipse
titlegetREMLabelOf
linenumberstrue
getUniqueValue
linenumberstrue
const sysId = s_form.getUniqueValue();
const currentRecord = new SimpleRecordif (s_form.getValue('name').match(/[\/|_*]/g))table);
currentRecord.get(sysId, ()=> {
  s_form.addErrorMessage(`Field "${s_form.getREMLabelOf('name')}" contains invalid characters.`);
}if (currentRecord.type == 'unavailable') {
    return false; // abort form submit
  }
});

s_form.

getREMValue

getValue(fieldName)


This method gets the attribute value.returns the internal (written down to the database) value of the specified field.

Warning

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
Object
String

This method returns

the current attribute object

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


Example:

Code Block
languagejs
themeEclipse
titlegetREMValue
linenumberstrue
js
themeEclipse
titlegetValue
linenumberstrue
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 {
    if (!!s_form.getREMValue('state')) {
  s_form.hideFieldMsgaddInfoMessage('state'Users schedule is not defined');
    }
  });
}

s_form.

getSections

getDisplayValue(fieldName)

Using this method, you can get an array of sections.

Return:

TypeDescriptionArray of HTML elementsThe form sections.

s_form.getSectionNames()

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

Return:

TypeDescriptionArray of stringsThis method returns array containing section names.

s_form.getTableName()

This method returns the table name to which the specified record relates.

Note

The method returns system table name, not the table title. Example:


This method returns the displayed value of the field.

Parameter(s):

NameTypeMandatoryDefault value
fieldNameStringYN


Return:

TypeDescription
StringThe displayed value of the specified field.


Example:

Code Block
languagejs
themeEclipse
titlegetDisplayValue
linenumberstrue
s_form.addInfoMessage(`Service "${s_form.getDisplayValue('service')}" is no available`);


s_form.goBack()


This method allows to perform redirect to the previous page; if not possible then redirect direction is a list view of the current essence (for example, to a list of incidents out of a incident record).

Table nameitsm_incidentTable titleIncidents


Return:

System table name

Type

Description

VoidThis method does not return a valueString.

Example:

Code Block
languagejs
themeEclipse
titlegetTableNamegoBack
linenumberstrue
if (['article', 'model'].includes(s_form.getTableNamehasChanges())) {
    s_form.setSectionMandatory('Review', truesave().then(() => s_form.goBack());
} else {
    s_form.setSectionMandatory('Review', falsegoBack();
}


s_form.

getUniqueValue

hasChanges()


This method returns the unique record ID (sys_id)allows to get information whether a record form has been changed or not.


Return:

Type

Description

StringReturns the record ID
BooleanThe method returns 'true' if any changes were made on the record form; otherwise, it returns
NULL
'false'.

Example:


Code Block
languagejs
themeEclipse
titlegetUniqueValuehasChanges
linenumberstrue
const sysId = if (s_form.getUniqueValuehasChanges();) {
const currentRecord = new SimpleRecord(s_form.tablesave();
currentRecord.get(sysId, ()=> {
  if (currentRecord.type == 'unavailable') {
    return false; // abort form submit
  }
});

s_form.getValue(fieldName)

This method returns the internal (written down to the database) value of the specified field.

WarningIsDisplayValue 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
then(() => s_form.goBack());
} else {
    s_form.goBack();
}

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
fieldNameStringYN

Return:

TypeDescriptionString

This method returns the internal (written down to the database) value of the specified field.

inputStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlehideFieldMsg
linenumberstrue
if (!!s_form.getValue('state')) {
  s_form.hideFieldMsg('state'

Example:

Code Block
languagejs
themeEclipse
titlegetValue
linenumberstrue
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

hideRelatedLists(

fieldName

)

This method returns the displayed value of the field.

Parameter(s):

NameTypeMandatoryDefault valuefieldNameStringYN

Using this method, you can hide all related lists on the form.


Return:

TypeDescription
StringThe displayed value of the specified field.

Example:

VoidThis method does not return a value.


Code Block
languagejs
themeEclipse
titlegetDisplayValuehideRelatedList
linenumberstrue
if (s_form.addInfoMessage(`Service "${getValue('type') == 'internal') {
  s_form.getDisplayValuehideRelatedLists('service')}" is no available`);;
}

s_form.

goBack

isMandatory(fieldName)


This method allows to perform redirect to the previous page; if not possible then redirect direction is a list view of the current essence (for example, to a list of incidents out of a incident record).is used to define if the specified field is mandatory or not.

Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN

Return:

TypeDescription
Void
BooleanThis method
does not return a value
returns 'true' if the field is mandatory; otherwise returns 'false'.

Example:

Code Block
languagejs
themeEclipse
titlegoBacks_form.isMandatory
linenumberstrue
if (s_form.hasChanges()) {
    s_form.save().thenisMandatory(('state') =>&& !s_form.goBackgetValue('state'));
} else {
    s_form.goBack(addInfoMessage('State cannot be None');
}

s_form.

hasChanges

hideRelatedList(relListTitle)

This method allows to get information whether a record form has been changed or not.

Using this method, you can specify a related list you want to hide.


Parameter(s):

NameTypeMandatoryDefault Value
relListTitleStringYN


Return:

TypeDescription
Boolean
Void
The method returns 'true' if any changes were made on the record form; otherwise, it returns 'false'
This method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlehasChangeshideRelatedList
linenumberstrue
if (s_form.hasChangesgetValue('type')) {
    s_form.save().then(() => s_form.goBack());
} else {
   == 'external') {
  s_form.goBack(hideRelatedList('Customer');
}


s_form.

hideFieldMsg

isNewRecord(

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 ValueinputStringYN

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


Return:

TypeDescription
VoidThis method does not return a value
BooleanIf the record was never saved then this method returns TRUE; otherwise, it returns FALSE.


Example:

Code Block
languagejs
themeEclipse
titlehideFieldMsgisNewRecord
linenumberstrue
if (!!s_form.isNewRecord()) {
  await s_form.getValuesetValue('state')) {, 'new');
  s_form.hideFieldMsgsetReadOnly('state', true);
}

s_form.

hideRelatedLists()Using this method, you can hide all related lists on the form.

isReadonly(fieldName)


This method is used to define if the specified field is editable or read-only.

Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN

Return:

TypeDescription
Void
BooleanThis method
does not return a value.
returns 'true' if the field is read-only; otherwise returns 'false'.

Example:

Code Block
languagejs
themeEclipse
titlehideRelatedLists_from.isReadonly
linenumberstrue
if (!s_form.getValueisReadonly('typestate') == 'internal') {
    await s_form.hideRelatedLists(setValue('state', 'new');
}

s_form.

hideRelatedList

isSectionVisible(

relListTitle

sectionName)


Using this method, you can specify a related list you want to hideThis method defines if a specified section is visible or not.


Parameter(s):

NameTypeMandatoryDefault Value
relListTitle
sectionName
String
stringYN


Return:

TypeDescription
Void
BooleanThis method
does not return a value.
Example:
returns TRUE if the section is visible; otherwise, it returns FALSE.


Code Block
languagejs
themeEclipse
titlehideRelatedListgetSectionNames
linenumberstrue
if (s_form.getValueisSectionVisible('typeInstructions') == 'external') {
  s_form.hideRelatedListaddInfoMessage('Customer'Check out the "Instructions" section', 5000);
}

s_form.

isNewRecord

isValid()


If the record was never saved, this method returns TRUE; otherwise, it returns FALSEThis method is used to define if the specified form is valid or not.

Return:

TypeDescription
Boolean
If the record was never saved then this method returns TRUE; otherwise, it returns FALSE
This method returns 'true' if the form is valid; otherwise, returns 'false'.

Example:

Code Block
languagejs
themeEclipse
titleisNewRecords_form.isValid
linenumberstrue
if (!!s_form.isNewRecordisValid()) {
  await  s_form.setValueaddErrorMessage('state', 'new');
  s_form.setReadOnly('state', trueThis form is invalid');
}

s_form.

isSectionVisible

isVisible(

sectionName

fieldName)


This method defines if a specified section is used to define if the specified field is visible or not.

Parameter(s):

NameTypeMandatoryDefault Value
sectionName
fieldName
string
StringYN

Return:

TypeDescription
Boolean
This
The method returns
TRUE
'true' if the
section
field is visible; otherwise
, it
returns
FALSE
'false'.

Example:

Code Block
languagejs
themeEclipse
titlegetSectionNamess_form.isVisible
linenumberstrue
if (s_form.isSectionVisibleisVisible('Instructionsstate')) {
    s_form.addInfoMessagesetSectionDisplay('Check out the "Instructions" sectionControls', 5000true);
}

s_form.removeOption(fieldName, choiceValue)


Using this method, you can specify and delete an option from the list.

Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
choiceValueStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleremoveOption
linenumberstrue
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 the record without leaving its form (just updating).


Return:

TypeDescription
ObjectThis method returns a promise containing specific data.


Code Block
languagejs
themeEclipse
titlesave()
linenumberstrue
s_form.save().finally(__resolveServerResponse);


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:

Code Block
languagejs
themeEclipse
titlesetLabelOf
linenumberstrue
if (s_form.table == 'user') {  
  s_form.setLabelOf('email', 'Email'); 
} else {
  s_form.setLabelOf('email', 'Personal Email'); 
}

s_form.setMandatory(fieldName, mandatory)


This method is used to change a specified field to mandatory field, i.e., it cannot be null.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
mandatoryBooleanYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetMandatory
linenumberstrue
const mandatoryColumn =
  (scriptType == 'onChange' || scriptType == 'onCellEdit');
s_form.setMandatory('column_id', mandatoryColumn);

s_form.setReadOnly(fieldName, readOnly)


This method is used to change a specified field to read-only or editable.

If the field is mandatory, it cannot be set to read-only. First, use the s_form.setMandatory() method and then make it read-only.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
readOnlyBooleanYN


Return:

TypeDescription
VoidThis method does not return a value


Example:

Code Block
languagejs
themeEclipse
titlesetReadOnly
linenumberstrue
if (!!s_form.getValue('any_tables')){
  s_form.setReadOnly('table_id', true);
  s_form.setMandatory('table_id', false);
  s_form.setVisible('table_id', false);
}

s_form.setREMLabelOf(fieldName, value)


This method allows changing the displayable message gets the plain text value of the REM attribute label.

Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN
valueStringYN

Return:

Type

Description

StringThis method returns new value of the attribute label.

Example:

Code Block
languagejs
themeEclipse
titlesetREMLabelOf
linenumberstrue
if (s_form.tablegetTableName() == 'user') {
  
  s_form.setREMLabelOf('email', 'Email');
} else {
    s_form.setREMLabelOf('email', 'Personal Email');
}


s_form.setREMMandatory(fieldName, mandatory)


This method allows to make a field specified by REM attribute mandatory.

Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN
mandatoryBooleanY'true'

Return:

Type

Description

BooleanThis method returns "'true" ' if its execution has been successful; otherwise, it returns "'false"'.

Example:

Code Block
languagejs
themeEclipse
titlesetREMMandatory
linenumberstrue
const mandatoryColumnisDeliveryFilled =
  (scriptType == 'onChange' || scriptType == 'onCellEdit' !!s_form.getValue('delivery');
s_form.setREMMandatory('column_idphone', mandatoryColumnisDeliveryFilled);


s_form.setREMReadOnly(fieldName,

readonly

readOnly)


This method allows to make a field specified by REM attribute read-only.


Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN
readonlyreadOnlyBooleanY'true'


Return:

Type

Description

BooleanThis method returns "'true" ' if its execution has been successful; otherwise, it returns "'false"'.

Example:

Code Block
languagejs
themeEclipse
titlesetREMReadOnly
linenumberstrue
if (!!s_form.isNewRecord()) {
    s_form.setValuesetREMValue('state', 'new');
    s_form.setREMReadOnly('state', true);
}

s_form.setREMValue(fieldName, databaseValue)


This method allows to set a value of the REM attribute label.


Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN
databaseValueObjectYN


Return:

Type

Description

VoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titlesetREMValue
linenumberstrue
if (!!s_form.isNewRecord()) {
    s_form.setREMValue('namestate', 'Name created by systemnew');
}


s_form.setREMVisiblle(fieldName, display)


This method allows to define visibility of the field specified by REM attribute.

Parameter(s):

Name

Type

Mandatory

Default Value

fieldNameStringYN
displayBooleanYN

Return:

Type

Description

VoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titlesetREMvisible
s_form.setREMVisible('chronologyadditional_info', !s_form.isNewRecord());

s_form.setSectionDisplay(sectionName, display)


Using this method, you can specify a section you want to hide.


Parameter(s):

NameTypeMandatoryDefault Value
sectionNameStringYN
displayBooleanYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetSectionDisplay
linenumberstrue
if (s_form.getValue('state') == '7') { // Completed
  s_form.setSectionDisplay('Closure Information', true);
  s_form.setSectionMandatory('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.setSectionMandatory('Closure Information', false);
}


s_form.setValue(fieldName, databaseValue)


This method sets the field value. 

Warning

IsDisplayValue parameter has been maintained in earlier versions but will be deprecated after version 1.1. Avoid using it in your scripts.


Note

Use s_form.clearValue() method for field clearing instead of setting an empty string value.

Also please note that this method is asynchronous; for better performing, use the await keyword like shown in the code example below.


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
databaseValueStringYN


Return:

TypeDescription
VoidThis method returns a Promise object.


Example:

Code Block
languagejs
themeEclipse
titlesetValue
linenumberstrue
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)


This method allows to manage displaying of the fields that were added to the form through the Form Layout. With this method, you can hide or show the field. The hidden field state is similar as if this field has been removed from the form view. 


Note

Hiding a field for which the mandatory attribute is set on a column level (including mandatory override described in the Column Overriding article) will lead to validation errors after the form submitting from the client-side.

Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
displayBooleanYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titlesetVisible
linenumberstrue
if (!s_form.isNewRecord()) {
  s_form.setVisible('subject', true);
  s_form.setVisible('reason', false);
}

s_form.showFieldMsg(fieldName, message, type)


This method is used to display a message containing 'info', 'error', or 'warning' value under the specified form field. 


Parameter(s):

NameTypeMandatoryDefault Value
fieldNameStringYN
messageStringYN
typeStringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

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


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


Code Block
languagejs
themeEclipse
titleshowFieldMsg
linenumberstrue
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(listTitle)


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


Parameter(s):

NameTypeMandatoryDefault Value

listTitle

StringYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

Code Block
languagejs
themeEclipse
titleshowRelatedList
linenumberstrue
s_form.showRelatedList('UI Action');

s_form.submit()


This method allows to submit the record form.


Return:

TypeDescription
VoidThis method does not return a value.


Table of Contents
absoluteUrltrue