Skip to main content

Form rule functions

Hide Fields#

Specify the form fields to be hide.

Syntax:

new NameSpace("formRule").hideFields(["fieldName1","fieldName2"]);

Returns: List<FormRule>

Example:

return formRule().hideFields(["fieldName1","fieldName2"]); 

Show Fields#

Specify the form fields to be show.

Syntax:

new NameSpace("formRule").showFields(["fieldName1","fieldName2"]);

Returns: List<FormRule>

Example:

return formRule().showFields(["fieldName1","fieldName2"]); 

Enable Fields#

Specify the form fields to be enabled.

Syntax:

new NameSpace("formRule").enableFields(["fieldName1","fieldName2"]);

Returns: List<FormRule>

Example:

return formRule().enableFields(["fieldName1","fieldName2"]); 

Disable Fields#

Specify the form fields to be disabled.

Syntax:

new NameSpace("formRule").disableFields(["fieldName1","fieldName2"]);

Returns: List<FormRule>

Example:

return formRule().disableFields(["fieldName1","fieldName2"]); 

Set Mandatory#

Specify the form fields to set mandatory

Syntax:

new NameSpace("formRule").setMandatory(["fieldName1","fieldName2"]);

Returns: List<FormRule>

Example:

return formRule().setMandatory(["fieldName1","fieldName2"]); 

Remove Mandatory#

Specify the form fields to remove mandatory

Syntax:

new NameSpace("formRule").removeMandatory(["fieldName1","fieldName2"]);

Returns: List<FormRule>

Example:

return formRule().removeMandatory(["fieldName1","fieldName2"]); 

Show Sections#

Specify the sections to be shown.

Syntax:

new NameSpace("formRule").showSections(["sectionName1","sectionName2"]);

Returns: List<FormRule>

Example:

return formRule().showSections(["sectionName1","sectionName2"]); 

Hide Sections#

Specify the sections to be hide.

Syntax:

new NameSpace("formRule").hideSections(["sectionName1","sectionName2"]);

Returns: List<FormRule>

Example:

return formRule().hideSections(["sectionName1","sectionName2"]); 

Set Picklist Filters#

Specify the form fields to set picklist filter.

Syntax:

new NameSpace("formRule").applyEnumFilter(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.pick_list_custom_zone = ["Choice 1","Choice 2"];fieldValueMap.multi_select_custom_zone = ["Choice 1","Choice 2"];return formRule().applyEnumFilter(fieldValueMap);

Apply Lookup Filter#

Specify the records to be shown in the lookup field dropdown. If the records are to be filtered by the record's name, use 'nameVsValue'. If the records are to be filtered by the record's ID, use 'idVsValue'. If the records are to be filtered by the condition use "applyFilterWithCondition" method.

Syntax:

new NameSpace("formRule").applyFilter(Map fieldValueMap); // for applyFilter without contion object new NameSpace("formRule").applyFilterWithCondition(Map nameVsCondition); // for applyFilterWithCondition

Returns: List<FormRule>

Example:


// for applyFilter without contion objectfieldValueMap = {};nameVsValue = {};nameVsValue.name = ["recordName"];idVsValue = {};idVsValue.id=[recordid1, recordid2];fieldValueMap.lookup_zone_m_custom_zone = nameVsValue;fieldValueMap.lookup_zone_s_custom_zone = idVsValue;return formRule().applyFilter(fieldValueMap);
// for applyFilterWithConditioncategory = 4;subcategory = 1;
fieldValueMap = {};nameVsCondition = {};
conditionmap1 = {};conditionmap1.operatorId = 3;conditionmap1.fieldName = "category";conditionmap1.value = category;conditionmap1.operator = "IS";
conditionmap2 = {};conditionmap2.operatorId = 3;conditionmap2.fieldName = "lookup_test_workorder";conditionmap2.value = subcategory;conditionmap2.operator = "IS";
conditionmap = {};conditionmap.put("1", conditionmap1);conditionmap.put("2", conditionmap2);
nameVsCondition.put("conditions", conditionmap);nameVsCondition.put("pattern", "(1 AND 2)");  fieldValueMap.parentWO = nameVsCondition;return formRule().applyFilterWithCondition(fieldValueMap);

Set Values#

Specify the fields to Set Value.

Single Line/Email/Multi Line#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = "fieldValue";
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.single_line_custom_zone = "test";fieldValueMap.multi_line_small_custom_zone = "okay okay\"lms test's";return formRule().setValue(fieldValueMap);

Pick List#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = "fieldValue";
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.pick_list_custom_zone = "Choice 1";return formRule().setValue(fieldValueMap);

Multi Select#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = ["Choice 1","Choice 2"];
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.multi_select_custom_zone =["Choice 1","Choice 2"];return formRule().setValue(fieldValueMap);

Boolean#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = true/false ;
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.boolean_custom_zone =  true;return formRule().setValue(fieldValueMap);

Number/Time/Date/DateTime/Decimal/Duration/Currency#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = Long fieldValue;
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.date_custom_zone = 1701887400000;fieldValueMap.time_custom_zone_1 = 36000000;fieldValueMap.datetime_custom_zone = 1701957407000;fieldValueMap.number_custom_zone = 2;fieldValueMap.decimal_custom_zone = 7.844;fieldValueMap.duration_custom_zone = 950400;fieldValueMap.currency_custom_zone = 44445;return formRule().setValue(fieldValueMap);

Single Lookup#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = Long recordId;
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.lookup_zone_s_custom_zone = lookupRecordId;return formRule().setValue(fieldValueMap);

Multi Lookup#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = [Long recordId1,Long recordId2];
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.lookup_zone_s_custom_zone =[lookupRecordId1,lookupRecordId2];return formRule().setValue(fieldValueMap);

URL Field#

Syntax:

fieldValueMap = {};
fieldValueMap.fieldName = [String Name,String href];
new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};fieldValueMap.url_field_custom_zone =["Name","href"];return formRule().setValue(fieldValueMap);

Team/Staff#

Syntax:

fieldValueMap = {};
value = {}; value.assignedTo = Long staffId;
value.assignmentGroup = Long teamId; new NameSpace("formRule").setValue(Map fieldValueMap);

Returns: List<FormRule>

Example:

fieldValueMap = {};value = {};value.assignedTo = staffId;value.assignmentGroup = teamId;fieldValueMap.assignment = value;return formRule().setValue(fieldValueMap);