query needs to be dynamically created based on the search fields using a!queryentity ?

GLOB_ArrayFilterGeneration
================================

= with(
  local!arrayLength: if(
    or( isnull(ri!valueArray) , all(
      rule!isTextNullOrBlank( text: _ ),
      ri!valueArray
    )),
    0,
    count(
      ri!valueArray
    )
  ),
  if(
    local!arrayLength = 0,
    null(),
    rule!GLOB_Filters(
      operators_txt: repeat(
        local!arrayLength,
        ri!operator_txt
      ),
      fields_txt: repeat(
        local!arrayLength,
        ri!field_txt
      ),
      values: ri!valueArray
    )
  )
)

= load(
  local!gridSelection: a!gridSelection(
    pagingInfo: rule!RTRR_getDefaultPagingInfo(
      null
    )
  ),
  local!defaultGridSelection: a!gridSelection(
    pagingInfo: rule!RTRR_getDefaultPagingInfo(
      null
    )
  ),
  local!selectedWellboreId_int,
  local!UWISearch_txt:if(ri!reentry=true,ri!UWI_txt,""),
  local!wellNameSearch_txt:if(ri!reentry=true,ri!wellName_txt,""),
  local!licenseNoSearch_txt:if(ri!reentry=true,ri!licenseNo_txt,""),
  local!decisionRequiredBy_date,
  local!decisionRequiredBySearch_date,
  local!businessUnitTokenArray_txt,
  local!businessUnitSearchArray_txt:if(ri!reentry=true,ri!businessUnitArray_txt,""),
  local!operatingDistrictTokenArray_txt,
  local!operatingDistrictSearchArray_txt:if(ri!reentry=true,ri!operatingDistrictArray_txt,""),
  local!AMUTokenArray_txt,
  local!AMUSearchArray_txt:if(ri!reentry=true,ri!AMUArray_txt,""),
  local!provinceTokenArray_txt,
  local!provinceSearchArray_txt:if(ri!reentry=true,ri!provinceArray_txt,""),
  local!decisionRequiredByBeginSearch_date:if(ri!reentry=true,ri!decisionRequiredByBegin_date,""),
  local!decisionRequiredByEndSearch_date:if(ri!reentry=true,ri!decisionRequiredByEnd_date,""),
  local!abandonByDateOperatorSearch_txt:if(ri!reentry=true,ri!abandonByDateOperator_txt,""),
  local!abandonByDateBeginSearch_date:if(ri!reentry=true,ri!abandonByDateBegin_date,""),
  local!abandonByDateEndSearch_date:if(ri!reentry=true,ri!abandonByDateEnd_date,""),
  local!operatorSearch_txt:if(ri!reentry=true,ri!operator_txt,""),
  local!wellStatusSearch_txt:if(ri!reentry=true,ri!wellStatus_txt,""),
  local!abandonByReasonSearch_txt:if(ri!reentry=true,ri!abandonByReason_txt,""),
  local!searchchoice:if(ri!reentry=true,ri!searchchoice,""),
  local!range:if(ri!reentry=true,ri!range,""),
  local!TWPStart:if(ri!reentry=true,ri!TWPStart,""),
  local!Twpend:if(ri!reentry=true,ri!Twpend,""),
  local!RangedStart:if(ri!reentry=true,ri!RangedStart,""),
  local!rangeend:if(ri!reentry=true,ri!rangeend,""),
  local!meridianStart:if(ri!reentry=true,ri!meridianStart,""),
  local!meridianend:if(ri!reentry=true,ri!meridianend,""),
  local!Blkstart:if(ri!reentry=true,ri!Blkstart,""),
  local!sheetsart:if(ri!reentry=true,ri!sheetsart,""),
  local!sheetend:if(ri!reentry=true,ri!sheetend,""),
  local!PTNStart:if(ri!reentry=true,ri!PTNStart,""),
  local!PTNend:if(ri!reentry=true,ri!PTNend,""),
  local!Subdstart:if(ri!reentry=true,ri!Subdstart,""),
  local!Subdend:if(ri!reentry=true,ri!Subdend,""),
  local!Blkend:if(ri!reentry=true,ri!Blkend,""),
  local!SelectedWellList: {},
  local!decision_txt: "Retire",
  local!showSearchFields:not(ri!reentry),
  local!decisionComments_txt,
  ri!operator_txt: "Between",
    ri!abandonByDateOperator_txt: "Between",
  with(
    a!formLayout(
      label: "Select Wells to Retain or Retire",
      firstColumnContents: {
        if(
          local!showSearchFields=true,
          {
            a!sectionLayout(
              label: "Search Fields",
              firstColumnContents: {
                a!textField(
                  label: "Well Name",
                  labelPosition: "ADJACENT",
                  value: ri!wellName_txt,
                  saveInto: ri!wellName_txt
                ),
                a!textField(
                  label: "UWI",
                  labelPosition: "ADJACENT",
                  value: ri!UWI_txt,
                  saveInto: ri!UWI_txt
                ),
                a!dropdownField(
                  label: "Decision Required By Date",
                  labelPosition: "ADJACENT",
                  choiceLabels: {
                    "After",
                    "Before",
                    "Between"
                  },
                  placeholderLabel: cons!GLOB_LABEL_DROPDOWN_PLACEHOLDER,
                  choiceValues: {
                    "After",
                    "Before",
                    "Between"
                  },
                  value: ri!operator_txt,
                  saveInto: ri!operator_txt
                ),
                if(
                  ri!operator_txt = "Between",
                  {
                    a!dateField(
                      label: "From",
                      labelPosition: "ADJACENT",
                      value: ri!decisionRequiredByBegin_date,
                      saveInto: ri!decisionRequiredByBegin_date
                    ),
                    a!dateField(
                      label: "To",
                      labelPosition: "ADJACENT",
                      value: ri!decisionRequiredByEnd_date,
                      saveInto: ri!decisionRequiredByEnd_date
                    )
                  },
                  if(
                    ri!operator_txt = "After",
                    a!dateField(
                      label: "From",
                      labelPosition: "ADJACENT",
                      value: ri!decisionRequiredByBegin_date,
                      saveInto: ri!decisionRequiredByBegin_date
                    ),
                    if(
                      ri!operator_txt = "Before",
                      a!dateField(
                        label: "To",
                        labelPosition: "ADJACENT",
                        value: ri!decisionRequiredByEnd_date,
                        saveInto: ri!decisionRequiredByEnd_date
                      ),
                      {}
                    )
                  )
                )
              },
              secondColumnContents: {
                a!textField(
                  label: "License Number",
                  labelPosition: "ADJACENT",
                  value: ri!licenseNo_txt,
                  saveInto: ri!licenseNo_txt
                ),
                a!textField(
                  label: "Well Status",
                  labelPosition: "ADJACENT",
                  value: ri!wellStatus_txt,
                  saveInto: ri!wellStatus_txt
                ),
                a!dropdownField(
                  label: "Abandon By Date",
                  labelPosition: "ADJACENT",
                  choiceLabels: {
                    "After",
                    "Before",
                    "Between"
                  },
                  placeholderLabel: cons!GLOB_LABEL_DROPDOWN_PLACEHOLDER,
                  choiceValues: {
                    "After",
                    "Before",
                    "Between"
                  },
                  value: ri!abandonByDateOperator_txt,
                  saveInto: ri!abandonByDateOperator_txt
                ),
                if(
                  ri!abandonByDateOperator_txt = "Between",
                  {
                    a!dateField(
                      label: "From",
                      labelPosition: "ADJACENT",
                      value: ri!abandonByDateBegin_date,
                      saveInto: ri!abandonByDateBegin_date
                    ),
                    a!dateField(
                      label: "To",
                      labelPosition: "ADJACENT",
                      value: ri!abandonByDateEnd_date,
                      saveInto: ri!abandonByDateEnd_date
                    )
                  },
                  if(
                    ri!abandonByDateOperator_txt = "After",
                    a!dateField(
                      label: "From",
                      labelPosition: "ADJACENT",
                      value: ri!abandonByDateBegin_date,
                      saveInto: ri!abandonByDateBegin_date
                    ),
                    if(
                      ri!abandonByDateOperator_txt = "Before",
                      a!dateField(
                        label: "To",
                        labelPosition: "ADJACENT",
                        value: ri!abandonByDateEnd_date,
                        saveInto: ri!abandonByDateEnd_date
                      ),
                      {}
                    )
                  )
                ),
                a!dropdownField(
                  label: "Abandon By Date Reason",
                  labelPosition: "ADJACENT",
                  choiceLabels: {
                    cons!RTRR_LABELS_ABANDON_BY_REASONS
                  },
                  placeholderLabel: cons!GLOB_LABEL_DROPDOWN_PLACEHOLDER,
                  choiceValues: {
                    cons!RTRR_LABELS_ABANDON_BY_REASONS
                  },
                  value: ri!abandonByReason_txt,
                  saveInto: ri!abandonByReason_txt
                )
              }
            ),
            a!sectionLayout(
              firstColumnContents: {
                rule!RTRR_ComponentBusinessUnitMultiSelect(
                  businessUnitArray_txt: ri!businessUnitArray_txt
                )
              },
              secondColumnContents: {
                rule!GLOB_EditableGridSingleTextColumn(
                  columnHeader_txt: "Operating District",
                  itemsArray_txt: ri!operatingDistrictArray_txt,
                  itemsTokenArray_txt: local!operatingDistrictTokenArray_txt,
                  linkLabel_txt: "+Add Operating District"
                )
              }
            ),
            a!sectionLayout(
              firstColumnContents: {
                rule!GLOB_EditableGridSingleTextColumn(
                  columnHeader_txt: "AMU",
                  itemsArray_txt: ri!AMUArray_txt,
                  itemsTokenArray_txt: local!AMUTokenArray_txt,
                  linkLabel_txt: "+Add AMU"
                )
              },
              secondColumnContents: {
                a!multipleDropdownField(
                  label: "Province",
                  choiceLabels: {
                    cons!RTRR_LABEL_DROPDOWN_PROVINCE
                  },
                  choiceValues: {
                    cons!RTRR_LABEL_DROPDOWN_PROVINCE
                  },
                  value: ri!provinceArray_txt,
                  saveInto: ri!provinceArray_txt
                )
              }
            ),
            a!sectionLayout(
              label : "Select By Location",
              firstColumnContents: {
                a!radioButtonField(
                  label:"",
                  choiceLabels: {"DLS","NTS"},
                  choiceValues: {"DLS","NTS"},
                  value:ri!searchchoice,
                  saveInto:ri!searchchoice
                )}
                ),
             
if(ri!searchchoice="DLS",rule!RTRR_GRIDComponentDLS(range:ri!range,TWPbegin:ri!TWPStart,rangedbegin:ri!RangedStart,Merbegin:ri!meridianStart,
Twpend:ri!Twpend,rangedend:ri!rangeend,merend:ri!meridianend
),{}),
if(ri!searchchoice="NTS",rule!RTRR_GRIDComponentNTS(range:ri!range,Sheetstart:ri!sheetsart,subdstart:ri!Subdstart,PTNStart:ri!PTNStart,
BLKStart:ri!Blkstart,Sheetend:ri!sheetend,Subdend:ri!Subdend,PTNend:ri!PTNend
),{})
          },
          {}
        ),
        if(
          local!showSearchFields = true,
          {},
          {
            with(
              local!businessUnitFilters: rule!GLOB_ArrayFilterGeneration(
                valueArray: local!businessUnitSearchArray_txt,
                operator_txt: "=",
                field_txt: "BusinessUnit"
              ),
              local!businessUnitLogicalExpression: if(
                rule!APN_isEmpty(
                  local!businessUnitSearchArray_txt
                ),
                null(),
                a!queryLogicalExpression(
                  operator: "OR",
                  filters: local!businessUnitFilters
                )
              ),
              local!AMUFilters: rule!GLOB_ArrayFilterGeneration(
                valueArray: local!AMUSearchArray_txt,
                operator_txt: "includes",
                field_txt: "AMU"
              ),
              local!AMULogicalExpression: if(
                rule!APN_isEmpty(
                  local!AMUSearchArray_txt
                ),
                null(),
                a!queryLogicalExpression(
                  operator: "OR",
                  filters: local!AMUFilters
                )
              ),
              local!provinceFilters: rule!GLOB_ArrayFilterGeneration(
                valueArray: local!provinceSearchArray_txt,
                operator_txt: "=",
                field_txt: "Province"
              ),
              local!provinceLogicalExpression: if(
                rule!APN_isEmpty(
                  local!provinceSearchArray_txt
                ),
                null(),
                a!queryLogicalExpression(
                  operator: "OR",
                  filters: local!provinceFilters
                )
              ),
              local!operatingDistrictFilters: rule!GLOB_ArrayFilterGeneration(
                valueArray: local!operatingDistrictSearchArray_txt,
                operator_txt: "includes",
                field_txt: "District"
              ),
              local!operatingDistrictLogicalExpression: if(
                rule!APN_isEmpty(
                  local!operatingDistrictSearchArray_txt
                ),
                null(),
                a!queryLogicalExpression(
                  operator: "OR",
                  filters: local!operatingDistrictFilters
                )
              ),
              local!query: rule!GLOB_QueryNestedFilters(
                pagingInfo: local!gridSelection.pagingInfo,
                textParams_txt: {
                  local!UWISearch_txt,
                  local!licenseNoSearch_txt,
                  local!wellNameSearch_txt,
                  local!wellStatusSearch_txt,
                  local!abandonByReasonSearch_txt,
                    {local!Subdstart,
                     if(and(rule!isValueNull(local!sheetend),
               rule!isValueNull(local!PTNend),
               rule!isValueNull(local!Subdend)),local!Subdstart,local!Subdend)
                  }
                  
                },
                queryColumns_txt: {
                    "WellName",
              "LicensedUWI",
              "LicenseNo",
              "DecisionRequiredByDate",
              "DRBDREASON",
              "District",
              "WellBoreID",
              "AMU",
              "Province",
              "LastProductionDate",
              "BusinessUnit",
              "SystemDecision",
              "SystemDecisionDate",
              "EngineerDecision",
              "GeologistDecision",
               "LandmanDecision" ,
               "AbandonByDate",
               "AbandonByReason",
                  "IHSStatus",
                  "WellStatus" ,
                 
                  "RigReleaseDate",
                  
                  
                },
                textOperations_txt: {
                  "includes",
                  "includes",
                  "includes",
                  "includes",
                  "=",
                   {">=","<=",">=","<="}
                },
                textColumns_txt: {
                  "LicensedUWI",
                  "LicenseNo",
                  "WellName",
                  "WellStatus",
                  "AbandonByReason",
                  {"SUBD","SUBD"}
                },
                
                integerParams_int:
               {local!TWPStart,
               if(and(rule!isValueNull(local!Twpend),
               rule!isValueNull(local!rangeend),
               rule!isValueNull(local!meridianend)),local!TWPStart,local!Twpend),
               local!RangedStart,
               if(and(rule!isValueNull(local!Twpend),
               rule!isValueNull(local!rangeend),
               rule!isValueNull(local!meridianend)),local!RangedStart,local!rangeend),
               local!meridianStart,
               if(and(rule!isValueNull(local!Twpend),
               rule!isValueNull(local!rangeend),
               rule!isValueNull(local!meridianend)),local!meridianStart,local!meridianend),
               
               local!sheetsart,
               if(and(rule!isValueNull(local!sheetend),
               rule!isValueNull(local!PTNend),
               rule!isValueNull(local!Subdend)),local!sheetsart,local!sheetend),
               local!PTNStart,
                 if(and(rule!isValueNull(local!sheetend),
               rule!isValueNull(local!PTNend),
               rule!isValueNull(local!Subdend)),local!PTNStart,local!PTNend),
               },
               
                integerOperations_txt:
                {">=","<=",">=","<=",">=","<=",">=","<=",">=","<="},
               
                integerColumns_txt:
                {"TWP","TWP","RGE","RGE","MER","MER","SHEET","SHEET","PTN","PTN"},
                dateParams_date: append(
                  {},
                  if(
                    local!operatorSearch_txt = "Between",
                    {
                      local!decisionRequiredByBeginSearch_date,
                      local!decisionRequiredByEndSearch_date
                    },
                    if(
                      local!operatorSearch_txt = "After",
                      local!decisionRequiredByBeginSearch_date,
                      local!decisionRequiredByEndSearch_date
                    )
                  ),
                  if(
                    local!abandonByDateOperatorSearch_txt = "Between",
                    {
                      local!abandonByDateBeginSearch_date,
                      local!abandonByDateEndSearch_date
                    },
                    if(
                      local!abandonByDateOperatorSearch_txt = "After",
                      local!abandonByDateBeginSearch_date,
                      local!abandonByDateEndSearch_date
                    )
                  )
                ),
                dateOperators_txt: append(
                  {},
                  if(
                    local!operatorSearch_txt = "After",
                    ">",
                    if(
                      local!operatorSearch_txt = "Before",
                      "<",
                      {
                        ">=",
                        "<="
                      }
                    )
                  ),
                  if(
                    local!abandonByDateOperatorSearch_txt = "After",
                    ">",
                    if(
                      local!abandonByDateOperatorSearch_txt = "Before",
                      "<",
                      {
                        ">=",
                        "<="
                      }
                    )
                  )
                ),
                dateColumns_txt: {
                  append(
                    {},
                    if(
                      local!operatorSearch_txt = "Between",
                      {
                        "DecisionRequiredByDate",
                        "DecisionRequiredByDate"
                      },
                      "DecisionRequiredByDate"
                    ),
                    if(
                      local!abandonByDateOperatorSearch_txt = "Between",
                      {
                        "AbandonByDate",
                        "AbandonByDate"
                      },
                      "AbandonByDate"
                    )
                  )
                },
                QueryLogicalExpressions: filter(
                  rule!GLOB_isValueNotNull,
                  append(
                    {},
                    local!businessUnitLogicalExpression,
                    local!AMULogicalExpression,
                    local!provinceLogicalExpression,
                    local!operatingDistrictLogicalExpression
                  )
                )
              ),
             
              local!IHSWellData: a!queryEntity(
                entity: cons!RTRR_ENTITY_WELLVIEWDATA ,
                query: local!query
              ),
              
              {
                a!sectionLayout(
                  label: "Search Results"&local!query,
                  firstColumnContents: {
                    rule!RTRR_GridDisplayWells(
                      gridSelection: local!gridSelection,
                      selectedWellboreIdList_int: ri!selectedWellboreIdList_int,
                      IHSWellData: local!IHSWellData,
                      selectedWellboreId_int: local!selectedWellboreId_int,
                      SelectedWellList: local!SelectedWellList
                    ),
                    a!buttonLayout(
                      primaryButtons: {
                        a!buttonWidget(
                          label: "Search Again",
                          value: true,
                          saveInto: {
                            local!showSearchFields << rule!APN_returnFirstInput(
                              true,
                              _
                            ),
                            local!selectedWellboreId_int << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            ri!selectedWellboreIdList_int << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            local!decision_txt << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            local!decisionComments_txt << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            ri!abandonByDate_date << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            ri!abandonByReasonKey_txt << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            ri!abandonByComment_txt << rule!APN_returnFirstInput(
                              null,
                              _
                            ),
                            local!gridSelection << rule!APN_returnFirstInput(
                              local!defaultGridSelection,
                              _
                            ),
                            local!SelectedWellList << rule!APN_returnFirstInput(
                              {},
                              _
                            ),
                  local!searchchoice << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!range << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!TWPStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Twpend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!RangedStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!rangeend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!meridianStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!meridianend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Blkstart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!sheetsart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!sheetend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!PTNStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!PTNend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Subdstart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Subdend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Blkend << rule!APN_returnFirstInput(
                    null,
                    _
                  )
                          },
                          submit: false
                        )
                      }
                    )
                  }
                ),
                if(
                  rule!isTextNullOrBlank(
                    local!selectedWellboreId_int
                  ),
                  {},
                  rule!RTRR_SectionDisplayComments(
                    wellboreId_int: local!selectedWellboreId_int
                  )
                ),
                rule!RTRR_SectionGatherDecisionInformation(
                  abandonByDate_date: ri!abandonByDate_date,
                  abandonByReasonKey_txt: ri!abandonByReasonKey_txt,
                  selectedWellboreIdList_int: ri!selectedWellboreIdList_int,
                  abandonByComment_txt: ri!abandonByComment_txt,
                  SelectedWellList: local!SelectedWellList,
                  decision_txt: local!decision_txt,
                  decisionComments_txt: local!decisionComments_txt
                )
              }
            )
          }
        )
      },
      buttons: if(
        local!showSearchFields = false,
        {
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidgetSubmit(
                label: "Submit",
                style: "PRIMARY",
                confirmMessage: if(
                  local!decision_txt = "Retain",
                  cons!RTRR_MESSAGE_CONFIRM_RETAIN,
                  ""
                ),
                value: cons!GLOB_VALUE_BUTTON_SUBMIT,
                saveInto: {
                  ri!buttonAction_txt,
                  ri!Decision.Comments << rule!APN_returnFirstInput(
                    local!decisionComments_txt,
                    _
                  ),
                  ri!Decision.Decision << rule!APN_returnFirstInput(
                    local!decision_txt,
                    _
                  )
                }
              )
            },
            secondaryButtons: {
              a!buttonWidgetSubmit(
                label: "Cancel",
                style: "DESTRUCTIVE",
                value: cons!GLOB_VALUE_BUTTON_CANCEL,
                saveInto: ri!buttonAction_txt,
                skipValidation: true
              )
            }
          )
        },
        {
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidget(
                label: "Search",
                style: "PRIMARY",
                saveInto: {
                  local!abandonByReasonSearch_txt << rule!APN_returnFirstInput(
                    ri!abandonByReason_txt,
                    _
                  ),
                  local!provinceSearchArray_txt << rule!APN_returnFirstInput(
                    ri!provinceArray_txt,
                    _
                  ),
                  local!AMUSearchArray_txt << rule!APN_returnFirstInput(
                    ri!AMUArray_txt,
                    _
                  ),
                  local!licenseNoSearch_txt << rule!APN_returnFirstInput(
                    ri!licenseNo_txt,
                    _
                  ),
                  local!wellStatusSearch_txt << rule!APN_returnFirstInput(
                    ri!wellStatus_txt,
                    _
                  ),
                  local!UWISearch_txt << rule!APN_returnFirstInput(
                    ri!UWI_txt,
                    _
                  ),
                  local!businessUnitSearchArray_txt << rule!APN_returnFirstInput(
                    ri!businessUnitArray_txt,
                    _
                  ),
                  local!operatingDistrictSearchArray_txt << rule!APN_returnFirstInput(
                    ri!operatingDistrictArray_txt,
                    _
                  ),
                  local!decisionRequiredByBeginSearch_date << rule!APN_returnFirstInput(
                    ri!decisionRequiredByBegin_date,
                    _
                  ),
                  local!decisionRequiredByEndSearch_date << rule!APN_returnFirstInput(
                    ri!decisionRequiredByEnd_date,
                    _
                  ),
                  local!operatorSearch_txt << rule!APN_returnFirstInput(
                    ri!operator_txt,
                    _
                  ),
                  local!abandonByDateBeginSearch_date << rule!APN_returnFirstInput(
                    ri!abandonByDateBegin_date,
                    _
                  ),
                  local!abandonByDateEndSearch_date << rule!APN_returnFirstInput(
                    ri!abandonByDateEnd_date,
                    _
                  ),
                  local!abandonByDateOperatorSearch_txt << rule!APN_returnFirstInput(
                    ri!abandonByDateOperator_txt,
                    _
                  ),
                  local!gridSelection.pagingInfo.startIndex << rule!APN_returnFirstInput(
                    1,
                    _
                  ),
                  local!showSearchFields << rule!APN_returnFirstInput(
                    false,
                    _
                  ),
                  local!wellNameSearch_txt << rule!APN_returnFirstInput(
                    ri!wellName_txt,
                    _
                  ),
                  local!searchchoice << rule!APN_returnFirstInput(
                    ri!searchchoice,
                    _
                  ),
                  local!range << rule!APN_returnFirstInput(
                    ri!range,
                    _
                  ),
                  local!TWPStart << rule!APN_returnFirstInput(
                    ri!TWPStart,
                    _
                  ),
                  local!Twpend << rule!APN_returnFirstInput(
                    ri!Twpend,
                    _
                  ),
                  local!RangedStart << rule!APN_returnFirstInput(
                    ri!RangedStart,
                    _
                  ),
                  local!rangeend << rule!APN_returnFirstInput(
                    ri!rangeend,
                    _
                  ),
                  local!meridianStart << rule!APN_returnFirstInput(
                    ri!meridianStart,
                    _
                  ),
                  local!meridianend << rule!APN_returnFirstInput(
                    ri!meridianend,
                    _
                  ),
                  local!Blkstart << rule!APN_returnFirstInput(
                    ri!Blkstart,
                    _
                  ),
                  local!sheetsart << rule!APN_returnFirstInput(
                    ri!sheetsart,
                    _
                  ),
                  local!sheetend << rule!APN_returnFirstInput(
                    ri!sheetend,
                    _
                  ),
                  local!PTNStart << rule!APN_returnFirstInput(
                    ri!PTNStart,
                    _
                  ),
                  local!PTNend << rule!APN_returnFirstInput(
                    ri!PTNend,
                    _
                  ),
                  local!Subdstart << rule!APN_returnFirstInput(
                    ri!Subdstart,
                    _
                  ),
                  local!Subdend << rule!APN_returnFirstInput(
                    ri!Subdend,
                    _
                  ),
                  local!Blkend << rule!APN_returnFirstInput(
                    ri!Blkend,
                    _
                  )
                  
                }
              ),
              a!buttonWidget(
                label: "Clear",
                saveInto: {
                  local!abandonByReasonSearch_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!abandonByReason_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!provinceSearchArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  ri!provinceArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!AMUSearchArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!provinceTokenArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  ri!AMUArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!licenseNoSearch_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!licenseNo_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!wellStatus_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!wellStatusSearch_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!UWISearch_txt << rule!APN_returnFirstInput(
                    "",
                    _
                  ),
                  ri!UWI_txt << rule!APN_returnFirstInput(
                    "",
                    _
                  ),
                  local!businessUnitSearchArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  ri!businessUnitArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!businessUnitTokenArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!operatingDistrictSearchArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  ri!operatingDistrictArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!operatingDistrictTokenArray_txt << rule!APN_returnFirstInput(
                    {},
                    _
                  ),
                  local!decisionRequiredByBeginSearch_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!decisionRequiredByBegin_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!decisionRequiredByEndSearch_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!decisionRequiredByEnd_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!operatorSearch_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!abandonByDateBeginSearch_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!abandonByDateBegin_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!abandonByDateEndSearch_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!abandonByDateEnd_date << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!abandonByDateOperator_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!abandonByDateOperatorSearch_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!operator_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!gridSelection.pagingInfo.startIndex << rule!APN_returnFirstInput(
                    1,
                    _
                  ),
                  local!wellNameSearch_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!wellName_txt << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  
                  local!range << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!TWPStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Twpend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!RangedStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!rangeend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!meridianStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!meridianend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Blkstart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!sheetsart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!sheetend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!PTNStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!PTNend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Subdstart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Subdend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  local!Blkend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!searchchoice << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!range << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!TWPStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!Twpend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!RangedStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!rangeend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!meridianStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!meridianend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!Blkstart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!sheetsart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!sheetend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!PTNStart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!PTNend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!Subdstart << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!Subdend << rule!APN_returnFirstInput(
                    null,
                    _
                  ),
                  ri!Blkend << rule!APN_returnFirstInput(
                    null,
                    _
                  )
                }
              )
            },
            secondaryButtons: {
              a!buttonWidgetSubmit(
                label: "Cancel",
                style: "DESTRUCTIVE",
                value: cons!GLOB_VALUE_BUTTON_CANCEL,
                saveInto: ri!buttonAction_txt,
                skipValidation: true
              )
            }
          )
        }
      )
    )
  )
)
= with(
  local!isSearchParamsNull: all(
    rule!isValueNull,
    {
      append( {}, ri!textParams_txt , ri!dateParams_date , ri!integerParams_int)
    }
  ),
  local!isQueryExpressionsNull: rule!isObjectNull(
    ri!QueryLogicalExpressions
  ),
  if(
    and(
      local!isSearchParamsNull,
      local!isQueryExpressionsNull
    ),
    a!query(
      selection: a!querySelection(
        columns: {
          apply(
            a!queryColumn(
              field: _
            ),
            ri!queryColumns_txt
          )
        }
      ),
      pagingInfo: ri!pagingInfo
    ),
    if(
      and(
        local!isQueryExpressionsNull,
        not(
          local!isSearchParamsNull
        )
      ),
      a!query(
        selection: a!querySelection(
          columns: {
            apply(
              a!queryColumn(
                field: _
              ),
              ri!queryColumns_txt
            )
          }
        ),
        pagingInfo: ri!pagingInfo,
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters: rule!GLOB_Filters(
            values: ri!textParams_txt,
            fields_txt: ri!textColumns_txt,
            operators_txt: ri!textOperations_txt,
            dateValues_date : ri!dateParams_date,
            dateFields_txt: ri!dateColumns_txt,
            dateOperators_txt: ri!dateOperators_txt,
            integerValues_int: ri!integerParams_int,
            integerFields_txt: ri!integerColumns_txt,
            integerOperators_txt: ri!integerOperations_txt
          )
        )
      ),
      if(
        and(
          local!isSearchParamsNull,
          not(
            local!isQueryExpressionsNull
          )
        ),
        a!query(
          selection: a!querySelection(
            columns: {
              apply(
                a!queryColumn(
                  field: _
                ),
                ri!queryColumns_txt
              )
            }
          ),
          pagingInfo: ri!pagingInfo,
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            logicalExpressions: ri!QueryLogicalExpressions
          )
        ),
        a!query(
          selection: a!querySelection(
            columns: {
              apply(
                a!queryColumn(
                  field: _
                ),
                ri!queryColumns_txt
              )
            }
          ),
          pagingInfo: ri!pagingInfo,
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: rule!GLOB_Filters(
              values: ri!textParams_txt,
              fields_txt: ri!textColumns_txt,
              operators_txt: ri!textOperations_txt,
              dateValues_date : ri!dateParams_date,
              dateFields_txt: ri!dateColumns_txt,
              dateOperators_txt: ri!dateOperators_txt,
              integerValues_int: ri!integerParams_int,
              integerFields_txt: ri!integerColumns_txt,
              integerOperators_txt: ri!integerOperations_txt
            ),
            logicalExpressions: ri!QueryLogicalExpressions
          )
        )
      )
    )
  )
)
= with(
  local!hasTextValues: and( rule!GLOB_isValueNotNull( ri!values) , length(
    ri!values
  ) > 0),
  local!hasDateValues: and( rule!GLOB_isValueNotNull(ri!dateValues_date) , length(
    ri!dateValues_date
  ) > 0 ) ,
  local!hasIntegerValues: and( rule!GLOB_isValueNotNull(ri!integerValues_int),
    length( ri!integerValues_int
  ) > 0),
  /* textField( value: */
  apply(
    a!queryFilter(
      field: _,
      operator: _,
      value: _
    ),
    merge(
      append(
        if(
          local!hasTextValues,
          index(
            ri!fields_txt,
            difference(
              rule!GLOB_createArray(
                count(
                  ri!values
                )
              ),
              wherecontains(
                {
                  null()
                },
                ri!values
              )
            )
          ),
          {}
        ),
        if(
          local!hasDateValues,
          index(
            ri!dateFields_txt,
            difference(
              rule!GLOB_createArray(
                count(
                  ri!dateValues_date
                )
              ),
              wherecontains(
                {
                  todate(
                    null()
                  )
                },
                ri!dateValues_date
              )
            )
          ),
          {}
        ),
        if(
          local!hasIntegerValues,
          index(
            ri!integerFields_txt,
            difference(
              rule!GLOB_createArray(
                count(
                  ri!integerValues_int
                )
              ),
              wherecontains(
                {
                  tointeger(
                    null()
                  )
                },
                ri!integerValues_int
              )
            )
          ),
          {}
        )
      ),
      append(
        if(
          local!hasTextValues,
          index(
            ri!operators_txt,
            difference(
              rule!GLOB_createArray(
                count(
                  ri!values
                )
              ),
              wherecontains(
                {
                  null()
                },
                ri!values
              )
            )
          ),
          {}
        ),
        if(
          local!hasDateValues,
          index(
            ri!dateOperators_txt,
            difference(
              rule!GLOB_createArray(
                count(
                  ri!dateValues_date
                )
              ),
              wherecontains(
                {
                  todate(
                    null()
                  )
                },
                ri!dateValues_date
              )
            )
          ),
          {}
        ),
        if(
          local!hasIntegerValues,
          index(
            ri!integerOperators_txt,
            difference(
              rule!GLOB_createArray(
                count(
                  ri!integerValues_int
                )
              ),
              wherecontains(
                {
                  tointeger(
                    null()
                  )
                },
                ri!integerValues_int
              )
            )
          ),
          {}
        )
      ),
      filter(
        rule!GLOB_isValueNotNull,
        {
          ri!values,
          ri!dateValues_date,
          ri!integerValues_int
        }
      )
    )
  )
  /*)*/
)

Hi ,

I have an action where user can do multiple search options to get the related data from DB as below

 

 

I am facing an issue in amending the following section queries  and based on the user enterable values , the following query needs to be executed along  with the other search fields.

104,1,5 ;;;;;;;;;;;106,23,6

select * from vw_rtrr_wellreport

where (TWP =104 and RGE >=1 and MER >=5)

or (TWP >= 104 and TWP <= 106)

or (TWP =106 and RGE <=23 and MER <=6)

 

currently I am able to execute the following query but , it has to modify with the above query

select * from vw_rtrr_wellreport where (TWP >=104 and TWP <=106) and (RGE >=1 and RGE <=23) and (MER >=5 and MER <=6)

attached all the related form , please help me.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    I recommend looking into a!logicalExpression which gives you the options to OR groups of a!queryFilters or other a!logicalExpressions(), which should give you want you want if I'm understanding your question correctly. docs.appian.com/.../fnc_system_a_querylogicalexpression.html

    For your example, you would create 3 logical expressions for "(TWP =104 and RGE >=1 and MER >=5)", "(TWP >= 104 and TWP <= 106)", and "(TWP =106 and RGE <=23 and MER <=6)" and wrap all three with a parent logical expression with the operator attribute set to "OR". Then pass this logical expression into your queryEntity
  • Yes , I have to amend in the existing code along wth the other search fields.
  • +1
    Certified Lead Developer
    in reply to Soujanya B

    Hi Soujanya,

    Can you try to create a logical expression in the below format and try to use the same in your code after necessary modifications.

    logicalExpression: a!queryLogicalExpression(
    operator: "OR",
    logicalExpressions: {
    a!forEach(
    items: ri!yourInputCDT,
    /* Create a display cdt with the fromTWP, toTWP, fromRGE, toRGE, fromMER, toMER values or if they alredy exist in a cdt use that cdt*/
    expression: /* Have the below code in an expression rule so that you can use it here*/
    a!queryLogicalExpression(
    operator: "AND",
    filters: if(
    rule!APN_isEmpty(
    ri!yourInputCDT
    ),
    /*have a default filter here*/"",
    {
    if(
    rule!APN_isEmpty(
    index(
    ri!yourInputCDT,
    "fromTWP",
    {}
    )
    ),
    "",
    a!queryFilter(
    field: "TWP",
    operator: ">=",
    value: index(
    ri!yourInputCDT,
    "fromTWP",
    {}
    )
    )
    ),
    if(
    rule!APN_isEmpty(
    index(
    ri!yourInputCDT,
    "toTWP",
    {}
    )
    ),
    "",
    a!queryFilter(
    field: "TWP",
    operator: "<=",
    value: index(
    ri!yourInputCDT,
    "toTWP",
    {}
    )
    )
    ),
    if(
    rule!APN_isEmpty(
    index(
    ri!yourInputCDT,
    "fromRGE",
    {}
    )
    ),
    "",
    a!queryFilter(
    field: "RGE",
    operator: ">=",
    value: index(
    ri!yourInputCDT,
    "fromRGE",
    {}
    )
    )
    ),
    if(
    rule!APN_isEmpty(
    index(
    ri!yourInputCDT,
    "toRGE",
    {}
    )
    ),
    "",
    a!queryFilter(
    field: "RGE",
    operator: "<=",
    value: index(
    ri!yourInputCDT,
    "toRGE",
    {}
    )
    )
    ),
    if(
    rule!APN_isEmpty(
    index(
    ri!yourInputCDT,
    "fromMER",
    {}
    )
    ),
    "",
    a!queryFilter(
    field: "MER",
    operator: ">=",
    value: index(
    ri!yourInputCDT,
    "fromMER",
    {}
    )
    )
    ),
    if(
    rule!APN_isEmpty(
    index(
    ri!yourInputCDT,
    "toMER",
    {}
    )
    ),
    "",
    a!queryFilter(
    field: "MER",
    operator: "<=",
    value: index(
    ri!yourInputCDT,
    "toMER",
    {}
    )
    )
    )
    }
    )
    )
    )
    }
    )

    Let me know if have any doubts.

  • I am in to 16.3 version of Appian , I don't think we have foreach in 16.3.
    I don't have CDT to save those values , let me create and save those values to it.
    I can use apply () to achieve right.
    I will check and let me know if I face any issue.
  • RTRR_DLSSearch - subrule

     a!queryLogicalExpression(
     operator: "OR",
     logicalExpressions: {
       
       a!queryLogicalExpression(
     operator: "AND",
     filters:{
       
       if(
     rule!APN_isEmpty(
     ri!DLSSearch
     ),
     "",
     {
       
       if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "TWPStart",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "TWP",
     operator: "=",
     value: index(
     ri!DLSSearch,
     "TWPStart",
     {}
     )
     )
     ),
      if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "RGEStart",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "RGE",
     operator: ">=",
     value: index(
     ri!DLSSearch,
     "RGEStart",
     {}
     )
     )
     ),
      if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "MERStart",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "MER",
     operator: ">=",
     value: index(
     ri!DLSSearch,
     "MERStart",
     {}
     )
     )
     )
     })
     }
     ),
       a!queryLogicalExpression(
     operator: "AND",
     filters:{
       
       if(
     rule!APN_isEmpty(
     ri!DLSSearch
     ),
     "",
     {
       
       if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "TWPStart",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "TWP",
     operator: ">=",
     value: index(
     ri!DLSSearch,
     "TWPStart",
     {}
     )
     )
     ),
      if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "TWPEnd",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "TWP",
     operator: "<=",
     value: index(
     ri!DLSSearch,
     "TWPEnd",
     {}
     )
     )
     )
     })
     }
     ),
        
       a!queryLogicalExpression(
     operator: "AND",
     filters:{
       
       if(
     rule!APN_isEmpty(
     ri!DLSSearch
     ),
     "",
     {
       
       if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "TWPEnd",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "TWP",
     operator: "=",
     value: index(
     ri!DLSSearch,
     "TWPEnd",
     {}
     )
     )
     ),
      if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "RGEEnd",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "RGE",
     operator: "<=",
     value: index(
     ri!DLSSearch,
     "RGEEnd",
     {}
     )
     )
     ),
     if(
     rule!APN_isEmpty(
     index(
     ri!DLSSearch,
     "MEREnd",
     {}
     )
     ),
     "",
     a!queryFilter(
     field: "MER",
     operator: "<=",
     value: index(
     ri!DLSSearch,
     "MEREnd",
     {}
     )
     )
     )
     })
     }
     )
    }
    )
     
    

     

    MAin rule

    ====

    = load(
      local!gridSelection: a!gridSelection(
        pagingInfo: rule!RTRR_getDefaultPagingInfo(
          null
        )
      ),
      local!defaultGridSelection: a!gridSelection(
        pagingInfo: rule!RTRR_getDefaultPagingInfo(
          null
        )
      ),
      local!selectedWellboreId_int,
      local!UWISearch_txt:if(ri!reentry=true,ri!UWI_txt,""),
      local!wellNameSearch_txt:if(ri!reentry=true,ri!wellName_txt,""),
      local!licenseNoSearch_txt:if(ri!reentry=true,ri!licenseNo_txt,""),
      local!decisionRequiredBy_date,
      local!decisionRequiredBySearch_date,
      local!businessUnitTokenArray_txt,
      local!businessUnitSearchArray_txt:if(ri!reentry=true,ri!businessUnitArray_txt,""),
      local!operatingDistrictTokenArray_txt,
      local!operatingDistrictSearchArray_txt:if(ri!reentry=true,ri!operatingDistrictArray_txt,""),
      local!AMUTokenArray_txt,
      local!AMUSearchArray_txt:if(ri!reentry=true,ri!AMUArray_txt,""),
      local!provinceTokenArray_txt,
      local!provinceSearchArray_txt:if(ri!reentry=true,ri!provinceArray_txt,""),
      local!decisionRequiredByBeginSearch_date:if(ri!reentry=true,ri!decisionRequiredByBegin_date,""),
      local!decisionRequiredByEndSearch_date:if(ri!reentry=true,ri!decisionRequiredByEnd_date,""),
      local!abandonByDateOperatorSearch_txt:if(ri!reentry=true,ri!abandonByDateOperator_txt,""),
      local!abandonByDateBeginSearch_date:if(ri!reentry=true,ri!abandonByDateBegin_date,""),
      local!abandonByDateEndSearch_date:if(ri!reentry=true,ri!abandonByDateEnd_date,""),
      local!operatorSearch_txt:if(ri!reentry=true,ri!operator_txt,""),
      local!wellStatusSearch_txt:if(ri!reentry=true,ri!wellStatus_txt,""),
      local!abandonByReasonSearch_txt:if(ri!reentry=true,ri!abandonByReason_txt,""),
      local!searchchoice:if(ri!reentry=true,ri!searchchoice,""),
      local!range:if(ri!reentry=true,ri!range,""),
      local!TWPStart:if(ri!reentry=true,ri!TWPStart,""),
      local!Twpend:if(ri!reentry=true,ri!Twpend,""),
      local!RangedStart:if(ri!reentry=true,ri!RangedStart,""),
      local!rangeend:if(ri!reentry=true,ri!rangeend,""),
      local!meridianStart:if(ri!reentry=true,ri!meridianStart,""),
      local!meridianend:if(ri!reentry=true,ri!meridianend,""),
      local!Blkstart:if(ri!reentry=true,ri!Blkstart,""),
      local!sheetsart:if(ri!reentry=true,ri!sheetsart,""),
      local!sheetend:if(ri!reentry=true,ri!sheetend,""),
      local!PTNStart:if(ri!reentry=true,ri!PTNStart,""),
      local!PTNend:if(ri!reentry=true,ri!PTNend,""),
      local!Subdstart:if(ri!reentry=true,ri!Subdstart,""),
      local!Subdend:if(ri!reentry=true,ri!Subdend,""),
      local!Blkend:if(ri!reentry=true,ri!Blkend,""),
      local!SelectedWellList: {},
      local!decision_txt: "Retire",
      local!showSearchFields:not(ri!reentry),
      local!decisionComments_txt,
      ri!operator_txt: "Between",
        ri!abandonByDateOperator_txt: "Between",
      with(
        a!formLayout(
          label: "Select Wells to Retain or Retire",
          firstColumnContents: {
            if(
              local!showSearchFields=true,
              {
                a!sectionLayout(
                  label: "Search Fields",
                  firstColumnContents: {
                    a!textField(
                      label: "Well Name",
                      labelPosition: "ADJACENT",
                      value: ri!wellName_txt,
                      saveInto: ri!wellName_txt
                    ),
                    a!textField(
                      label: "UWI",
                      labelPosition: "ADJACENT",
                      value: ri!UWI_txt,
                      saveInto: ri!UWI_txt
                    ),
                    a!dropdownField(
                      label: "Decision Required By Date",
                      labelPosition: "ADJACENT",
                      choiceLabels: {
                        "After",
                        "Before",
                        "Between"
                      },
                      placeholderLabel: cons!GLOB_LABEL_DROPDOWN_PLACEHOLDER,
                      choiceValues: {
                        "After",
                        "Before",
                        "Between"
                      },
                      value: ri!operator_txt,
                      saveInto: ri!operator_txt
                    ),
                    if(
                      ri!operator_txt = "Between",
                      {
                        a!dateField(
                          label: "From",
                          labelPosition: "ADJACENT",
                          value: ri!decisionRequiredByBegin_date,
                          saveInto: ri!decisionRequiredByBegin_date
                        ),
                        a!dateField(
                          label: "To",
                          labelPosition: "ADJACENT",
                          value: ri!decisionRequiredByEnd_date,
                          saveInto: ri!decisionRequiredByEnd_date
                        )
                      },
                      if(
                        ri!operator_txt = "After",
                        a!dateField(
                          label: "From",
                          labelPosition: "ADJACENT",
                          value: ri!decisionRequiredByBegin_date,
                          saveInto: ri!decisionRequiredByBegin_date
                        ),
                        if(
                          ri!operator_txt = "Before",
                          a!dateField(
                            label: "To",
                            labelPosition: "ADJACENT",
                            value: ri!decisionRequiredByEnd_date,
                            saveInto: ri!decisionRequiredByEnd_date
                          ),
                          {}
                        )
                      )
                    )
                  },
                  secondColumnContents: {
                    a!textField(
                      label: "License Number",
                      labelPosition: "ADJACENT",
                      value: ri!licenseNo_txt,
                      saveInto: ri!licenseNo_txt
                    ),
                    a!textField(
                      label: "Well Status",
                      labelPosition: "ADJACENT",
                      value: ri!wellStatus_txt,
                      saveInto: ri!wellStatus_txt
                    ),
                    a!dropdownField(
                      label: "Abandon By Date",
                      labelPosition: "ADJACENT",
                      choiceLabels: {
                        "After",
                        "Before",
                        "Between"
                      },
                      placeholderLabel: cons!GLOB_LABEL_DROPDOWN_PLACEHOLDER,
                      choiceValues: {
                        "After",
                        "Before",
                        "Between"
                      },
                      value: ri!abandonByDateOperator_txt,
                      saveInto: ri!abandonByDateOperator_txt
                    ),
                    if(
                      ri!abandonByDateOperator_txt = "Between",
                      {
                        a!dateField(
                          label: "From",
                          labelPosition: "ADJACENT",
                          value: ri!abandonByDateBegin_date,
                          saveInto: ri!abandonByDateBegin_date
                        ),
                        a!dateField(
                          label: "To",
                          labelPosition: "ADJACENT",
                          value: ri!abandonByDateEnd_date,
                          saveInto: ri!abandonByDateEnd_date
                        )
                      },
                      if(
                        ri!abandonByDateOperator_txt = "After",
                        a!dateField(
                          label: "From",
                          labelPosition: "ADJACENT",
                          value: ri!abandonByDateBegin_date,
                          saveInto: ri!abandonByDateBegin_date
                        ),
                        if(
                          ri!abandonByDateOperator_txt = "Before",
                          a!dateField(
                            label: "To",
                            labelPosition: "ADJACENT",
                            value: ri!abandonByDateEnd_date,
                            saveInto: ri!abandonByDateEnd_date
                          ),
                          {}
                        )
                      )
                    ),
                    a!dropdownField(
                      label: "Abandon By Date Reason",
                      labelPosition: "ADJACENT",
                      choiceLabels: {
                        cons!RTRR_LABELS_ABANDON_BY_REASONS
                      },
                      placeholderLabel: cons!GLOB_LABEL_DROPDOWN_PLACEHOLDER,
                      choiceValues: {
                        cons!RTRR_LABELS_ABANDON_BY_REASONS
                      },
                      value: ri!abandonByReason_txt,
                      saveInto: ri!abandonByReason_txt
                    )
                  }
                ),
                a!sectionLayout(
                  firstColumnContents: {
                    rule!RTRR_ComponentBusinessUnitMultiSelect(
                      businessUnitArray_txt: ri!businessUnitArray_txt
                    )
                  },
                  secondColumnContents: {
                    rule!GLOB_EditableGridSingleTextColumn(
                      columnHeader_txt: "Operating District",
                      itemsArray_txt: ri!operatingDistrictArray_txt,
                      itemsTokenArray_txt: local!operatingDistrictTokenArray_txt,
                      linkLabel_txt: "+Add Operating District"
                    )
                  }
                ),
                a!sectionLayout(
                  firstColumnContents: {
                    rule!GLOB_EditableGridSingleTextColumn(
                      columnHeader_txt: "AMU",
                      itemsArray_txt: ri!AMUArray_txt,
                      itemsTokenArray_txt: local!AMUTokenArray_txt,
                      linkLabel_txt: "+Add AMU"
                    )
                  },
                  secondColumnContents: {
                    a!multipleDropdownField(
                      label: "Province",
                      choiceLabels: {
                        cons!RTRR_LABEL_DROPDOWN_PROVINCE
                      },
                      choiceValues: {
                        cons!RTRR_LABEL_DROPDOWN_PROVINCE
                      },
                      value: ri!provinceArray_txt,
                      saveInto: ri!provinceArray_txt
                    )
                  }
                ),
                a!sectionLayout(
                  label : "Select By Location",
                  firstColumnContents: {
                    a!radioButtonField(
                      label:"",
                      choiceLabels: {"DLS","NTS"},
                      choiceValues: {"DLS","NTS"},
                      value:ri!searchchoice,
                      saveInto:ri!searchchoice
                    )}
                    ),
                 
    if(ri!searchchoice="DLS",rule!RTRR_GRIDComponentDLS(range:local!range,TWPbegin:local!TWPStart,rangedbegin:local!RangedStart,
    Merbegin:local!meridianStart,
    Twpend:local!Twpend,rangedend:local!rangeend,merend:local!meridianend
    ),{}),
    if(ri!searchchoice="NTS",rule!RTRR_GRIDComponentNTS(range:local!range,Sheetstart:local!sheetsart,subdstart:local!Subdstart,PTNStart:local!PTNStart,
    BLKStart:local!Blkstart,Sheetend:local!sheetend,Subdend:local!Subdend,PTNend:local!PTNend
    ),{})
              },
              {}
            ),
            if(
              local!showSearchFields = true,
              {},
              {
                with(
                  local!businessUnitFilters: rule!GLOB_ArrayFilterGeneration(
                    valueArray: local!businessUnitSearchArray_txt,
                    operator_txt: "=",
                    field_txt: "BusinessUnit"
                  ),
                  local!businessUnitLogicalExpression: if(
                    rule!APN_isEmpty(
                      local!businessUnitSearchArray_txt
                    ),
                    null(),
                    a!queryLogicalExpression(
                      operator: "OR",
                      filters: local!businessUnitFilters
                    )
                  ),
                  local!AMUFilters: rule!GLOB_ArrayFilterGeneration(
                    valueArray: local!AMUSearchArray_txt,
                    operator_txt: "includes",
                    field_txt: "AMU"
                  ),
                  local!AMULogicalExpression: if(
                    rule!APN_isEmpty(
                      local!AMUSearchArray_txt
                    ),
                    null(),
                    a!queryLogicalExpression(
                      operator: "OR",
                      filters: local!AMUFilters
                    )
                  ),
                  local!provinceFilters: rule!GLOB_ArrayFilterGeneration(
                    valueArray: local!provinceSearchArray_txt,
                    operator_txt: "=",
                    field_txt: "Province"
                  ),
                  local!provinceLogicalExpression: if(
                    rule!APN_isEmpty(
                      local!provinceSearchArray_txt
                    ),
                    null(),
                    a!queryLogicalExpression(
                      operator: "OR",
                      filters: local!provinceFilters
                    )
                  ),
                  local!operatingDistrictFilters: rule!GLOB_ArrayFilterGeneration(
                    valueArray: local!operatingDistrictSearchArray_txt,
                    operator_txt: "includes",
                    field_txt: "District"
                  ),
                  local!operatingDistrictLogicalExpression: if(
                    rule!APN_isEmpty(
                      local!operatingDistrictSearchArray_txt
                    ),
                    null(),
                    a!queryLogicalExpression(
                      operator: "OR",
                      filters: local!operatingDistrictFilters
                    )
                  ),
                  local!DLSlogicalExpression : rule!RTRR_DLSSearchLogic(ri!RTRR_DLSSearch),
                  local!query: rule!GLOB_QueryNestedFilters(
                    pagingInfo: local!gridSelection.pagingInfo,
                    textParams_txt: {
                      local!UWISearch_txt,
                      local!licenseNoSearch_txt,
                      local!wellNameSearch_txt,
                      local!wellStatusSearch_txt,
                      local!abandonByReasonSearch_txt,
                        {local!Subdstart,
                         if(and(rule!isValueNull(local!sheetend),
                   rule!isValueNull(local!PTNend),
                   rule!isValueNull(local!Subdend)),local!Subdstart,local!Subdend)
                      }
                      
                    },
                    queryColumns_txt: {
                        "WellName",
                  "LicensedUWI",
                  "LicenseNo",
                  "DecisionRequiredByDate",
                  "DRBDREASON",
                  "District",
                  "WellBoreID",
                  "AMU",
                  "Province",
                  "LastProductionDate",
                  "BusinessUnit",
                  "SystemDecision",
                  "SystemDecisionDate",
                  "EngineerDecision",
                  "GeologistDecision",
                   "LandmanDecision" ,
                   "AbandonByDate",
                   "AbandonByReason",
                      "IHSStatus",
                      "WellStatus" ,
                     
                      "RigReleaseDate",
                      
                      
                    },
                    textOperations_txt: {
                      "includes",
                      "includes",
                      "includes",
                      "includes",
                      "=",
                       {">=","<=",">=","<="}
                    },
                    textColumns_txt: {
                      "LicensedUWI",
                      "LicenseNo",
                      "WellName",
                      "WellStatus",
                      "AbandonByReason",
                      {"SUBD","SUBD"}
                    },
                    
                   /* integerParams_int:
                    {local!TWPStart,local!Twpend,
                    local!RangedStart,local!rangeend,
                    local!meridianStart,local!meridianend
                    },
                    
                    
                   {local!TWPStart,
                   if(and(rule!isValueNull(local!Twpend),
                   rule!isValueNull(local!rangeend),
                   rule!isValueNull(local!meridianend)),local!TWPStart,local!Twpend),
                   local!RangedStart,
                   if(and(rule!isValueNull(local!Twpend),
                   rule!isValueNull(local!rangeend),
                   rule!isValueNull(local!meridianend)),local!RangedStart,local!rangeend),
                   local!meridianStart,
                   if(and(rule!isValueNull(local!Twpend),
                   rule!isValueNull(local!rangeend),
                   rule!isValueNull(local!meridianend)),local!meridianStart,local!meridianend),
                   
                   local!sheetsart,
                   if(and(rule!isValueNull(local!sheetend),
                   rule!isValueNull(local!PTNend),
                   rule!isValueNull(local!Subdend)),local!sheetsart,local!sheetend),
                   local!PTNStart,
                     if(and(rule!isValueNull(local!sheetend),
                   rule!isValueNull(local!PTNend),
                   rule!isValueNull(local!Subdend)),local!PTNStart,local!PTNend),
                   },
                   
                    integerOperations_txt:
                    {">=","<=",">=","<=",">=","<=",">=","<=",">=","<="},
                   
                    integerColumns_txt:
                    {"TWP","TWP","RGE","RGE","MER","MER","SHEET","SHEET","PTN","PTN"},*/
                    dateParams_date: append(
                      {},
                      if(
                        local!operatorSearch_txt = "Between",
                        {
                          local!decisionRequiredByBeginSearch_date,
                          local!decisionRequiredByEndSearch_date
                        },
                        if(
                          local!operatorSearch_txt = "After",
                          local!decisionRequiredByBeginSearch_date,
                          local!decisionRequiredByEndSearch_date
                        )
                      ),
                      if(
                        local!abandonByDateOperatorSearch_txt = "Between",
                        {
                          local!abandonByDateBeginSearch_date,
                          local!abandonByDateEndSearch_date
                        },
                        if(
                          local!abandonByDateOperatorSearch_txt = "After",
                          local!abandonByDateBeginSearch_date,
                          local!abandonByDateEndSearch_date
                        )
                      )
                    ),
                    dateOperators_txt: append(
                      {},
                      if(
                        local!operatorSearch_txt = "After",
                        ">",
                        if(
                          local!operatorSearch_txt = "Before",
                          "<",
                          {
                            ">=",
                            "<="
                          }
                        )
                      ),
                      if(
                        local!abandonByDateOperatorSearch_txt = "After",
                        ">",
                        if(
                          local!abandonByDateOperatorSearch_txt = "Before",
                          "<",
                          {
                            ">=",
                            "<="
                          }
                        )
                      )
                    ),
                    dateColumns_txt: {
                      append(
                        {},
                        if(
                          local!operatorSearch_txt = "Between",
                          {
                            "DecisionRequiredByDate",
                            "DecisionRequiredByDate"
                          },
                          "DecisionRequiredByDate"
                        ),
                        if(
                          local!abandonByDateOperatorSearch_txt = "Between",
                          {
                            "AbandonByDate",
                            "AbandonByDate"
                          },
                          "AbandonByDate"
                        )
                      )
                    },
                    QueryLogicalExpressions: filter(
                      rule!GLOB_isValueNotNull,
                      append(
                        {},
                        local!businessUnitLogicalExpression,
                        local!AMULogicalExpression,
                        local!provinceLogicalExpression,
                        local!operatingDistrictLogicalExpression,
                        local!DLSlogicalExpression
                       
                      )
                    )
                  ),
                 
                  local!IHSWellData: a!queryEntity(
                    entity: cons!RTRR_ENTITY_WELLVIEWDATA ,
                    query: local!query
                  ),
                  
                  {
                    a!sectionLayout(
                      label: "Search Results"&local!query,
                      firstColumnContents: {
                        rule!RTRR_GridDisplayWells(
                          gridSelection: local!gridSelection,
                          selectedWellboreIdList_int: ri!selectedWellboreIdList_int,
                          IHSWellData: local!IHSWellData,
                          selectedWellboreId_int: local!selectedWellboreId_int,
                          SelectedWellList: local!SelectedWellList
                        ),
                        a!buttonLayout(
                          primaryButtons: {
                            a!buttonWidget(
                              label: "Search Again",
                              value: true,
                              saveInto: {
                                local!showSearchFields << rule!APN_returnFirstInput(
                                  true,
                                  _
                                ),
                                local!selectedWellboreId_int << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                ri!selectedWellboreIdList_int << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                local!decision_txt << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                local!decisionComments_txt << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                ri!abandonByDate_date << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                ri!abandonByReasonKey_txt << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                ri!abandonByComment_txt << rule!APN_returnFirstInput(
                                  null,
                                  _
                                ),
                                local!gridSelection << rule!APN_returnFirstInput(
                                  local!defaultGridSelection,
                                  _
                                ),
                                local!SelectedWellList << rule!APN_returnFirstInput(
                                  {},
                                  _
                                ),
                      local!searchchoice << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!range << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!TWPStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Twpend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!RangedStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!rangeend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!meridianStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!meridianend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Blkstart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!sheetsart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!sheetend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!PTNStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!PTNend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Subdstart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Subdend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Blkend << rule!APN_returnFirstInput(
                        null,
                        _
                      )
                              },
                              submit: false
                            )
                          }
                        )
                      }
                    ),
                    if(
                      rule!isTextNullOrBlank(
                        local!selectedWellboreId_int
                      ),
                      {},
                      rule!RTRR_SectionDisplayComments(
                        wellboreId_int: local!selectedWellboreId_int
                      )
                    ),
                    rule!RTRR_SectionGatherDecisionInformation(
                      abandonByDate_date: ri!abandonByDate_date,
                      abandonByReasonKey_txt: ri!abandonByReasonKey_txt,
                      selectedWellboreIdList_int: ri!selectedWellboreIdList_int,
                      abandonByComment_txt: ri!abandonByComment_txt,
                      SelectedWellList: local!SelectedWellList,
                      decision_txt: local!decision_txt,
                      decisionComments_txt: local!decisionComments_txt
                    )
                  }
                )
              }
            )
          },
          buttons: if(
            local!showSearchFields = false,
            {
              a!buttonLayout(
                primaryButtons: {
                  a!buttonWidgetSubmit(
                    label: "Submit",
                    style: "PRIMARY",
                    confirmMessage: if(
                      local!decision_txt = "Retain",
                      cons!RTRR_MESSAGE_CONFIRM_RETAIN,
                      ""
                    ),
                    value: cons!GLOB_VALUE_BUTTON_SUBMIT,
                    saveInto: {
                      ri!buttonAction_txt,
                      ri!Decision.Comments << rule!APN_returnFirstInput(
                        local!decisionComments_txt,
                        _
                      ),
                      ri!Decision.Decision << rule!APN_returnFirstInput(
                        local!decision_txt,
                        _
                      )
                    }
                  )
                },
                secondaryButtons: {
                  a!buttonWidgetSubmit(
                    label: "Cancel",
                    style: "DESTRUCTIVE",
                    value: cons!GLOB_VALUE_BUTTON_CANCEL,
                    saveInto: ri!buttonAction_txt,
                    skipValidation: true
                  )
                }
              )
            },
            {
              a!buttonLayout(
                primaryButtons: {
                  a!buttonWidget(
                    label: "Search",
                    style: "PRIMARY",
                    saveInto: {
                      local!abandonByReasonSearch_txt << rule!APN_returnFirstInput(
                        ri!abandonByReason_txt,
                        _
                      ),
                      local!provinceSearchArray_txt << rule!APN_returnFirstInput(
                        ri!provinceArray_txt,
                        _
                      ),
                      local!AMUSearchArray_txt << rule!APN_returnFirstInput(
                        ri!AMUArray_txt,
                        _
                      ),
                      local!licenseNoSearch_txt << rule!APN_returnFirstInput(
                        ri!licenseNo_txt,
                        _
                      ),
                      local!wellStatusSearch_txt << rule!APN_returnFirstInput(
                        ri!wellStatus_txt,
                        _
                      ),
                      local!UWISearch_txt << rule!APN_returnFirstInput(
                        ri!UWI_txt,
                        _
                      ),
                      local!businessUnitSearchArray_txt << rule!APN_returnFirstInput(
                        ri!businessUnitArray_txt,
                        _
                      ),
                      local!operatingDistrictSearchArray_txt << rule!APN_returnFirstInput(
                        ri!operatingDistrictArray_txt,
                        _
                      ),
                      local!decisionRequiredByBeginSearch_date << rule!APN_returnFirstInput(
                        ri!decisionRequiredByBegin_date,
                        _
                      ),
                      local!decisionRequiredByEndSearch_date << rule!APN_returnFirstInput(
                        ri!decisionRequiredByEnd_date,
                        _
                      ),
                      local!operatorSearch_txt << rule!APN_returnFirstInput(
                        ri!operator_txt,
                        _
                      ),
                      local!abandonByDateBeginSearch_date << rule!APN_returnFirstInput(
                        ri!abandonByDateBegin_date,
                        _
                      ),
                      local!abandonByDateEndSearch_date << rule!APN_returnFirstInput(
                        ri!abandonByDateEnd_date,
                        _
                      ),
                      local!abandonByDateOperatorSearch_txt << rule!APN_returnFirstInput(
                        ri!abandonByDateOperator_txt,
                        _
                      ),
                      local!gridSelection.pagingInfo.startIndex << rule!APN_returnFirstInput(
                        1,
                        _
                      ),
                      local!showSearchFields << rule!APN_returnFirstInput(
                        false,
                        _
                      ),
                      local!wellNameSearch_txt << rule!APN_returnFirstInput(
                        ri!wellName_txt,
                        _
                      ),
                     local!searchchoice << rule!APN_returnFirstInput(
                        ri!searchchoice,
                        _
                      ),
                      a!save(ri!RTRR_DLSSearch.TWPStart ,local!TWPStart),
                      a!save(ri!RTRR_DLSSearch.RGEStart ,local!RangedStart),
                      a!save(ri!RTRR_DLSSearch.MERStart ,local!meridianStart),
                       a!save(ri!RTRR_DLSSearch.TWPEnd,if(and(rule!isValueNull(local!Twpend),
                   rule!isValueNull(local!rangeend),
                   rule!isValueNull(local!meridianend)),local!TWPStart,local!Twpend)),
                   
                    a!save(ri!RTRR_DLSSearch.RGEEnd,if(and(rule!isValueNull(local!Twpend),
                   rule!isValueNull(local!rangeend),
                   rule!isValueNull(local!meridianend)),local!RangedStart,local!rangeend)),
                   
                    a!save(ri!RTRR_DLSSearch.MEREnd,if(and(rule!isValueNull(local!Twpend),
                   rule!isValueNull(local!rangeend),
                   rule!isValueNull(local!meridianend)),local!meridianStart,local!meridianend)),
                      /* local!range << rule!APN_returnFirstInput(
                        ri!range,
                        _
                      ),
                      local!TWPStart << rule!APN_returnFirstInput(
                        ri!TWPStart,
                        _
                      ),
                      local!Twpend << rule!APN_returnFirstInput(
                        ri!Twpend,
                        _
                      ),
                      local!RangedStart << rule!APN_returnFirstInput(
                        ri!RangedStart,
                        _
                      ),
                      local!rangeend << rule!APN_returnFirstInput(
                        ri!rangeend,
                        _
                      ),
                      local!meridianStart << rule!APN_returnFirstInput(
                        ri!meridianStart,
                        _
                      ),
                      local!meridianend << rule!APN_returnFirstInput(
                        ri!meridianend,
                        _
                      ),
                      local!Blkstart << rule!APN_returnFirstInput(
                        ri!Blkstart,
                        _
                      ),
                      local!sheetsart << rule!APN_returnFirstInput(
                        ri!sheetsart,
                        _
                      ),
                      local!sheetend << rule!APN_returnFirstInput(
                        ri!sheetend,
                        _
                      ),
                      local!PTNStart << rule!APN_returnFirstInput(
                        ri!PTNStart,
                        _
                      ),
                      local!PTNend << rule!APN_returnFirstInput(
                        ri!PTNend,
                        _
                      ),
                      local!Subdstart << rule!APN_returnFirstInput(
                        ri!Subdstart,
                        _
                      ),
                      local!Subdend << rule!APN_returnFirstInput(
                        ri!Subdend,
                        _
                      ),
                      local!Blkend << rule!APN_returnFirstInput(
                        ri!Blkend,
                        _
                      )*/
                      
                    }
                  ),
                  a!buttonWidget(
                    label: "Clear",
                    saveInto: {
                      local!abandonByReasonSearch_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!abandonByReason_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!provinceSearchArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      ri!provinceArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!AMUSearchArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!provinceTokenArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      ri!AMUArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!licenseNoSearch_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!licenseNo_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!wellStatus_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!wellStatusSearch_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!UWISearch_txt << rule!APN_returnFirstInput(
                        "",
                        _
                      ),
                      ri!UWI_txt << rule!APN_returnFirstInput(
                        "",
                        _
                      ),
                      local!businessUnitSearchArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      ri!businessUnitArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!businessUnitTokenArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!operatingDistrictSearchArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      ri!operatingDistrictArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!operatingDistrictTokenArray_txt << rule!APN_returnFirstInput(
                        {},
                        _
                      ),
                      local!decisionRequiredByBeginSearch_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!decisionRequiredByBegin_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!decisionRequiredByEndSearch_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!decisionRequiredByEnd_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!operatorSearch_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!abandonByDateBeginSearch_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!abandonByDateBegin_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!abandonByDateEndSearch_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!abandonByDateEnd_date << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!abandonByDateOperator_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!abandonByDateOperatorSearch_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!operator_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!gridSelection.pagingInfo.startIndex << rule!APN_returnFirstInput(
                        1,
                        _
                      ),
                      local!wellNameSearch_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!wellName_txt << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      
                      local!range << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!TWPStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Twpend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!RangedStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!rangeend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!meridianStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!meridianend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Blkstart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!sheetsart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!sheetend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!PTNStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!PTNend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Subdstart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Subdend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      local!Blkend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!searchchoice << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!range << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!TWPStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!Twpend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!RangedStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!rangeend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!meridianStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!meridianend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!Blkstart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!sheetsart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!sheetend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!PTNStart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!PTNend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!Subdstart << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!Subdend << rule!APN_returnFirstInput(
                        null,
                        _
                      ),
                      ri!Blkend << rule!APN_returnFirstInput(
                        null,
                        _
                      )
                    }
                  )
                },
                secondaryButtons: {
                  a!buttonWidgetSubmit(
                    label: "Cancel",
                    style: "DESTRUCTIVE",
                    value: cons!GLOB_VALUE_BUTTON_CANCEL,
                    saveInto: ri!buttonAction_txt,
                    skipValidation: true
                  )
                }
              )
            }
          )
        )
      )
    )

    Hi,

    I am getting the following error

    Expression evaluation error in rule 'rtrr_formmultiplewelldecision' at function a!queryEntity [line 521]: Cannot apply operator [EQUALS] to field [TWP] when comparing to value [TypedValue[it=101,v={104}]].

  • It working..
    I have declared the cdt type as array in rule input to subrule.r
  • 0
    Certified Lead Developer
    in reply to Soujanya B
    I was checking your code good to hear that
  • Hi,

    I wan to declare a local variable of type RTRR_DLSSearch (CDT attached above) in an interface
  • 0
    Certified Lead Developer
    in reply to Soujanya B
    Please use the below code for casting the local variable to the specified cdt type.

    fn!cast(
    fn!typeof({type!RTRR_DLSSearch()}),
    /* enter your local varible here*/
    )