findDuplicate2SForm( )

Detect duplicate data across two-section form instances for a given item either within the flat section or the repeating section. The data is identified by a form ID which has duplicate item values for the search keys provided. The rule target should be on the corresponding repeating section item.

Use as many arguments as needed to fully defined the duplicate key.

  • You cannot use drop-downs, radio buttons, or checkbox values as function parameters or as a target.
  • Partial dates are accepted for date comparison.
    • The presence of any partial date among instances will make other full dates to be taken in the same format for comparison.

      For example, if there is a partial date instance 'UNK-JAN-2022', only the month and year values in other dates will be taken for the comparison, even if they are full dates. Similarly, if there is a partial date instance 'UNK-UNK-2022', only the year value will be used for comparison in all dates.

This is an aggregation function. The rule will be run for each form instance in the case where the target is on a two-section form.

Syntax

findDuplicate2SForm(formInstance, 'variable1', 'variable2',...)

Parameters

Note:

It is allowed to reuse variables passed into this function elsewhere in the rule expression, however you must add the variable as a parameter using single quotes.
Parameter Required/Optional Description
formInstance Optional Indicates the form instance in which the search for a duplicate is to be performed.
  • If this is null, the check is done for all instances of a two-section form.
  • If a value is provided, the check is done for table rows on the given two-section form instance.
variable(s) Required Item variable to check, passed in using single quotes.

Return value

Boolean (true or false) value:
  • True if duplicate values are found.
  • False if duplicate values are not found.

Examples

Example 3-61 Check to see if any duplicate two-section form instances exist with the same values for Lab and Test Name

// Given 5 two-section form instances with items "Lab" and "Test Name"
if (findDuplicate2sForm(null,'itmLab', 'itmTestName')) {
  return false;
} else {
  return true;
}

Example 3-62 Check to see is a form instance is a duplicate of another form instance

// Raise a query if 2 section form instance is duplicate of any other form instance

return findDuplicate2SForm(null, 'txt'); 

// Raise a query if 2 section table instance #2 is duplicate of any other table instance

var arrAE = findDuplicate2SForm(2, "txt");
return (arrAE.length <= 1)?false:true;