Form and Form Item APIs

The following are the JavaScript APIs that you can use to handle the data in the items:

Form Event Handlers

Description

fm.addCssClass(String fieldNames, String clsName, Integer index, String parent)

Adds any form item-related CSS classes under the Form Manager.

fm.addForm(Object formConfig)

Allows to add a sub-form within a form on the fly.

fm.addNext(String formId)

Adds a form in the multiform next to the available instance.

fm.model.applyModelData(Object obj, Boolean ignoreChanges, Boolean ignoreNullChanges)

Applies the changes made in the model data for the specific form items and then ignores the changes in the remaining form items.

fm.addTab(String tabPanelId, Object config, Integer index, String parent)Adds the tab to a Tab Panel form item.

fm.clearInvalid(String fieldName, Integer index, String parent)

fm.clearInvalid('EMAIL_ID');
// EMAIL_ID is the form item ID

Clears the values from the given invalid form item. The second and third parameters are required in case of a multiform only, where index of the multiform at which the form item is present must be the second parameter, and the multiform ID must be the third parameter.

fm.clearUploadPanel(Array fieldNames)

Resets the files inside the Upload Panel form items that exist in the form with respect to array of file names.

fm.clearValues(Array fieldNames, Boolean resetFlag, Integer index, String parent)

fm.clearValues(['EMAIL_ID']);
// EMAIL_ID is the form item ID

Clears the value of specific form item(s). When the 'resetFlag' parameter is set to true, the value of the form items is set to the initial values and when set to false, all the values on the form items are cleared. The default value for 'resetFalg' is false.

fm.createSliderThumbs(String fieldName, Integer noOfThumbs)Re-creates the slider thumbs dynamically for any one the Slider form item.
fm.displayMenu(String itemId, Object config, index, formId)Create and displays the menu for the Button form item.
fm.downLoadFile(Object config)Connects to the ExportServiceServelet and download a file from the server's uploaded files storage.

fm.exportForForms(String exportType, String title)

Exports the form content for printing or PDF conversion. It currently supports two export types – PDF and HTML.

fm.focus(String fieldName, Integer index, String parent)

fm.focus(['EMAIL_ID']);
// EMAIL_ID is the form item ID

Sets the focus to the given form item. The second and third parameters are required for multiform only, where the index of the multiform at which the form item is present must be the second parameter, and the multiform ID must be the third parameter.

fm.getComboStoreCount(String fieldName, Integer index, String parent)Get the store count in a Combo form item.

fm.getDropDownDisplayValue(String fieldName, String keyValue, Integer index, String parent)

Returns the display value for the corresponding key value of a drop-down. This is applicable for drop-downs only. In case of multiform, the third and fourth parameters are necessary. The index of the multiform at which the drop-down is present should be the third parameter. The multiform ID must be the fourth parameter.

fm.getFieldDom(String fieldName)

fm.getFieldDom(['EMAIL_ID']);
// EMAIL_ID is the form item ID
Gets the form item DOM for the particular item in a form.
fm.getFocussedField()Gets the currently focused form item on the form.

fm.getForm()

Returns the DOM object of the form.

fm.getFormTitle()

Returns the title as per the metadata of the request Master Form ID.

fm.getFormView()

Returns the reference of the wrapper panel under which the entire form is rendered. The app layer requires this view where it wants to render the form. This in turn helps the Form Manager to prepare the configurations for Lazzy Loading of the form items.

fm.getModelData()

Returns the form model data of the form items.

fm.getNumberOfSubForms(String formId)

Returns the number of instances or replica of the multiform is available in the screen.

fm.handlerEvent(String event, String fieldName, String value, Integer index, String parent)

Raises any event dynamically.

fm.isFieldValid(String fieldName, Integer index, String parent)

Validates a specific sub-form, such as in Tab Panels. It returns true if the sub-form is valid, else returns false.

fm.isFormDataChanged

Returns true or false to indicate whether the data displayed on the form is changed or not.

fm.isFormValid(Object config)

Validates all the form items on the form. It first looks up for custom form validation provided by the app layer. You can execute it in case it is provided, otherwise use the default validation process. Then, you can execute the post default validation process in case it is registered. This returns true if the form is valid, else returns false.

fm.isTabFormValid(Object config, Integer index, String parent)

Validates all the form items on the form by invoking the validateTabForm() method. It returns true if the form is valid, else returns false.

fm.isTabPanelExists()

Checks if the Tab Panel exists or not in the whole form. This method is included because when adding the form using the addform() method in the Form Manager instance, the form loses its padding when Tab Panel is rendered already. It returns True if the Tab Panel exists in the form, else returns False.

fm.isUploadPanelValid()

Validates the file upload form item. If the form item is mandatory and if the file queue is empty, then the form item is validated. It returns True if the file upload panel is valid, else returns False.

fm.markInvalid(String fieldName, String msgKey, Integer index, String parent)

fm.markInvalid('EMAIL_ID');
// EMAIL_ID is the form item ID

Marks the form item as invalid with the given message.
The message should be added in the bundle key associated with the form or form item.

fm.registerHandler(String event, String fieldName, Function handler, Object scope)

Event handlers for all form items have to be registered to the Form Manager using this method. This method updates the handler in the local register object to be used later when receiving the events from the model. This method requires the event for which the handler needs to be registered as the first parameter; Item ID of the form item for which the event needs to be registered as the second parameter; the call back function that needs to be executed for the passed event as the third parameter; and finally the scope in which the handler needs to be executed as the fourth parameter.

fm.reloadData(String fieldName)

Loads the app item with the recent data values.

fm.removeAt(Integer index, String formId)

Removes the multiform instance of a particular index.

fm.removeCssClass(String fieldNames, String clsName, Integer index, String parent)Removes any form item related CSS classes in a form or any sub-forms.

fm.removeForm(String formId)

Removes the sub-form from the main form.

fm.removeFrom(String formId, String start, String end)

Removes the multiform instances starting from a particular index onwards up to the ending index.

fm.removeTab(String tabPanelId, String formId, Integer index, String parent)Remove the tab from an Tab Panel item.

fm.reset()

Resets the values of the form items on the form. This method can be added in the click event of the Clear or Reset button of the form.

fm.resetSubForms()

Resets all the sub forms. It can be used to reset the sub form on click of the Reset button.

fm.resetUploadPanel()

Resets the files added in the Upload Panel form item.

fm.setActiveTab(String tabPanelId, String formId, Integer index, String parent)Activate a Tab Inner Panel. This method searches for the Tab Inner Panel, which is a sub-form (form ID). If it exists in the whole form, the method tries to match the sub-form's parent item's item ID with the Tab Panel ID and activate the respective tab.

fm.setAllowBlank(String fieldName, Boolean validation, Integer index, String parent)

Sets a specific form item to be blank irrespective of whether it is defined as a mandatory form item or not. The validation parameter must be a Boolean value – true or false.

fm.setAreaExpanded(String fieldName, Boolean flag, Integer index, String parent)Expand or collapses the form item set for the given form item.

fm.setDecimalPrecision(String fieldName, String decimalPrecision)

Sets the decimal precision for the Spinner form item. This needs to be implemented if the Spinner form item is part of a multiform.

fm.setDefaultValue(String fieldName, String value, Integer index, String parent)

Sets the decimal value for the Spinner form item only. This method takes the following four parameters – the Item ID of the spinner form item, the decimal value the needs to be set, the index of the multiform at which the spinner is present if at all the spinner is part of the multiform, and the multiform ID. The third and fourth parameters are applicable in case of multiform only.

fm.setDisabledDates(String fieldName, String disabledDates, String disabledDatesText, Integer index, String parent)

Disables the given dates in the given date form item. When the user selects the disabled date, the text given as disabled text is displayed.

fm.setDisabledDatesText(String fieldName, String disabledDatesText, Integer index, String parent)

Shows the given string when the user selects the disabled date on the given date control.

fm.setEnabledFields(Array fieldNames, Boolean enableFlag, Integer index, String parent)

Enables or disables the form items based on the showFlag value.

fm.setEnabledTabs(String tabPanelId, String formIds, Boolean enableflag, Integer index, String parent)Enables or disables the tabs in a Tab Panel item.

fm.setFocus(String fieldName, Integer index, String parent)

Sets the focus on a specific form item. It returns the JSON of the form item that is passed and its valid status.

fm.setLabel(String fieldName, String label, Integer index, String parent)

fm.setLabel('EMAIL_ID','Gmail ID');
// EMAIL_ID is the form item ID
// Gmail ID is the form item's caption or label
Sets the dynamic label for a item on the form.

fm.maxValue(String fieldName, String value, Integer index, String parent)

Sets the maximum value for the Date, Slider or Spinner form items. For the Date form item, the value must be in the DD/MM/YYYY format. The third and fourth parameters are required in case of a multiform only, where index of the multiform at which the Date, Slider or Spinner form item is present and parent is the multiform ID.

fm.minValue(String fieldName, String value, Integer index, String parent)

Sets the minimum value for the Date, Slider or Spinner form items. For the Date form item, the value must be in the DD/MM/YYYY format. The third and fourth parameters are required in case of a multiform only, where index of the multiform at which the Date, Slider or Spinner form item is present and parent is the multiform ID.

fm.setPanelTitle(String fieldName, String title, Integer index, String parent)Update the label or title for a specific form level containers, such as FIELD-SET, PANEL, INFOPANEL, UPLOADPANEL.
fm.setReadOnlyFields(Array fieldNames, Boolean readOnlyFlag, Integer index, String parent)Makes read-only any form item rendered under 'this' Form Manager instance.
fm.setStepValue(String fieldName, String stepValue, Integer index, String parent)Sets the step value for the Spinner form item.

fm.setVisibleFields(String fieldNames, Boolean showFlag, Integer index, String parent)

Shows or hides the form items based on the showFlag value.

fm.submitForm(Object md)Submits the form model data to the server and gets the result.

fm.updateComboRawStore(String fieldName, Array keyArr, Array valueArr, Integer index, String parent)

Updates the given combo item with the given array of keys and array of values. It is applicable for drop-downs, item selector, icon combo, auto suggest, and image panels only. For image panel, the keys must be the IDs of the images and the values must be the source (src) of the images. The fourth and fifth parameters are required in case of multiform only, where index of the multiform at which the form item is present is the fourth parameter and multiform ID is the fifth parameter.

fm.uploadFile(String state, Function handler)

Uploads the file in queue state and call backs the appropriate handler invoked by the developer to update the status.

fm.validateFields(String fieldName)

Validates a specific form item. It returns true if the form item is valid, else returns false.

fm.validateFormPanelTabs(Array tabFormNames, String tabPanelId, Integer index, String parent)Validate the specified tabs and the items on the form.

fm.reloadItemData(Array fieldValueList, Integer index, String formId)

  • fieldvalueList – This parameter is applicable for single and multi forms. Filter conditions can be given as follows:
canvas.form.listeners.BeneficiaryAdd = Class(canvas.Observable, 
{ 
	constructor: function(config) 
	{ 
		this.fm = config.fm; 
	}, 
	registerHandlers: function()
	{ 
	this.fm.registerHandler(CFEC.CHANGE,"Bank_Name_ID",
    function(fm, event, fieldName, value) 
	{ 
	  if (!canvas.isEmpty(value)) 
	  { 
		this.fm.reloadItemData([
		{ 
			itemId : 'Branch_Name_ID', 
			filters : { BANK_NAME : [value] } 
		}]); 
	  } 
	}); 
	} 
}); 
CFLR.registerListener("BENE_DETAILS_ID", canvas.form.listeners.BeneficiaryAdd); 
  • Index and formId – These parameters are applicable for multiforms. These two parameters must be provided along with the fieldvalueList.

Auto-populates the dependent form item's values based on the values selected in the independent form items. For more information, refer Auto-populating Dependent Fields’ Values in Forms.

This API can only be used when the View ID is specified for the form item. The API does not apply when the raw keys: raw values are specified or when the data for the form item is being fetched through data support class.