search result shown before click of submit button

A Score Level 1

hi,

I have a search field in which i have search email text field and a grid. Values is saved in local ! searchemail variable.The search field should work after i click submit button ,  but its showing results whenever I click outside text box.

Please help.

attached code also.

load(
  local!caseId,
  local!search,
  local!exp,
  local!caseCategory,
  local!caseStatus,
  local!requestFromDate,
  local!requestToDate,
  local!toDate,
  local!allCases,
  local!department,
  local!searchEmail,
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20,
    sort: a!sortInfo(
      field: "rag_status",
      ascending: true()
    )
    /*sort: a!sortInfo(*/
      /*field: "case_id",*/
      /*ascending: false()*/
    /*)*/
  ),
  {
    a!sectionLayout(
      label: "Search Criteria",
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Case ID",
                  value: local!caseId,
                  saveInto: local!caseId
                ),
                a!dateField(
                  label: "From Date",
                  value: local!requestFromDate,
                  saveInto: local!requestFromDate
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Case Category",
                  placeholderLabel: "---Select a value---",
                  choiceLabels: cons!APAC_SGP_EMAIL_CASE_CATEGORY_LABELS,
                  choiceValues: cons!APAC_SGP_EMAIL_CASE_CATEGORY_VALUES,
                  value: local!caseCategory,
                  saveInto: local!caseCategory
                ),
                a!dateField(
                  label: "To Date",
                  value: local!requestToDate,
                  saveInto: local!requestToDate
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!dropdownField(
                  label: "Case Status",
                  placeholderLabel: "---Select a value---",
                  choiceLabels: cons!APAC_SGP_EMAIL_CASE_STATUS_LABELS,
                  choiceValues: cons!APAC_SGP_EMAIL_CASE_STATUS_VALUES,
                  value: local!caseStatus,
                  saveInto: local!caseStatus
                ),
                a!textField(
                  label: "Search Email",
                  value: local!searchEmail,
                  saveInto: local!searchEmail
                )
              }
            ),
            a!columnLayout(
              a!dropdownField(
                label: "Department",
                placeholderLabel: "----Select----",
                choiceLabels: cons!APAC_DD_DEPARTMENTS,
                choiceValues: cons!APAC_DD_DEPARTMENTS,
                value: local!department,
                saveInto: local!department
              )
            )
          }
        ),
        a!textField(
          readOnly: true()
        ),
        a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "Submit",
            value: ri!buttonAction,
            saveInto: {
              ri!buttonAction,
              a!save(
                local!pagingInfo.startIndex,
                1
              ),
              a!save(
                ri!caseDashboard.case_id,
                local!caseId
              ),
              a!save(
                ri!caseDashboard.case_status,
                local!caseStatus
              ),
              a!save(
                ri!caseDashboard.case_ctgry,
                local!caseCategory
              ),
              a!save(
                ri!caseDashboard.department,
                local!department
              ),
              a!save(
                ri!caseDashboard.creation_ts,
                local!requestFromDate
              ),
              a!save(
                local!toDate,
                local!requestToDate
              ),
              a!save(
              local!exp,
                local!searchEmail
              ),
            },
            style: "PRIMARY"
          ),
          secondaryButtons: a!buttonWidget(
            label: "Reset",
            value: ri!buttonAction,
            saveInto: {
              ri!buttonAction,
              a!save(
                local!caseId,
                null
              ),
              a!save(
                local!caseStatus,
                null
              ),
              a!save(
                local!caseCategory,
                null
              ),
              a!save(
                local!department,
                null
              ),
              a!save(
                local!requestFromDate,
                null
              ),
              a!save(
                local!requestToDate,
                null
              ),
              a!save(
                local!toDate,
                null
              ),
              a!save(
                ri!caseDashboard.case_id,
                null
              ),
              a!save(
                ri!caseDashboard.case_status,
                null
              ),
              a!save(
                ri!caseDashboard.case_ctgry,
                null
              ),
              a!save(
                ri!caseDashboard.department,
                null
              ),
              a!save(
                ri!caseDashboard.creation_ts,
                null
              ),
              a!save(local!searchEmail,null)
            }
          )
        )
      }
    ),
    a!sectionLayout(
      label: "Search Results",
      contents: {
        a!gridField(
          label: "",
          emptyGridMessage: "No Data to Display",
          data: rule!APAC_getEmailIntegrationCases(
            caseId: ri!caseDashboard.case_id,
            caseCategory: ri!caseDashboard.case_ctgry,
            caseStatus: ri!caseDashboard.case_status,
            requestFromDate: ri!caseDashboard.creation_ts,
            requestToDate: local!toDate,
            pagingInfo: local!pagingInfo,
            teamName: ri!teamName,
            department: ri!caseDashboard.department,
            searchEmail: local!searchEmail
          ),
          columns: {
            a!gridColumn(
              label: "Case ID",
              sortField: "case_id",
              value: a!linkField(
                links: {
                  a!recordLink(
                    label: fv!row.case_id,
                    recordType: cons!APAC_RECON_RECP_DASHBOARD,
                    identifier: fv!row.case_id
                  )
                }
              )
            ),
            a!gridColumn(
              label: "Case Category",
              sortField: "category_val",
              value: fv!row.category_val
            ),
            a!gridColumn(
              label: "Case Status",
              sortField: "status_val",
              value: fv!row.status_val
            ),
            a!gridColumn(
              label: "Department",
              sortField: "department",
              value: fv!row.department
            ),
            /*a!gridColumn(*/
            /*label: "Pending Reason",*/
            /*sortField: "reason",*/
            /*value: fv!row.reason*/
            /*),*/
            a!gridColumn(
              label: "Request Date",
              sortField: "creation_ts",
              value: if(
                isnull(
                  fv!row.creation_ts
                ),
                fv!row.creation_ts,
                datetext(
                  fv!row.creation_ts,
                  "default"
                )
              )
            ),
            a!gridColumn(
              label: "Assigned To",
              sortField: "assigned_to",
              value: rule!APAC_displayFullUserName(
                fv!row.assigned_to
              ),
              
            ),
            a!gridColumn(
              label: "From Email",
              sortField: "from_email",
              value: fv!row.from_email
            ),
            a!gridColumn(
              label: "To Email",
              sortField: "to_email",
              value: fv!row.to_email
            ),
            a!gridColumn(
              label: "Email Subject ",
              sortField: "email_subject",
              value: fv!row.email_subject
            ),
            a!gridColumn(
              label: "RAG Status",
              sortField: "rag_status",
              value: a!imageField(
                images: a!documentImage(
                  document: if(
                    cons!APAC_SGP_RAG_STATUS_VALUES[1] = trim(
                      fv!row.rag_status
                    ),
                    a!iconIndicator(
                      "PROGRESS_STOPPED"
                    ),
                    if(
                      cons!APAC_SGP_RAG_STATUS_VALUES[2] = trim(
                        fv!row.rag_status
                      ),
                      a!iconIndicator(
                        "PROGRESS_RUNNING"
                      ),
                      if(
                        cons!APAC_SGP_RAG_STATUS_VALUES[3] = trim(
                          fv!row.rag_status
                        ),
                        a!iconIndicator(
                          "PROGRESS_PAUSED"
                        ),
                        a!iconIndicator(
                          "PROGRESS_STOPPED"
                        )
                      )
                    )
                  ),
                  caption: if(
                    cons!APAC_SGP_RAG_STATUS_VALUES[1] = trim(
                      fv!row.rag_status
                    ),
                    cons!CNAM_RAG_STATUS_LABELS[3],
                    if(
                      cons!APAC_SGP_RAG_STATUS_VALUES[2] = trim(
                        fv!row.rag_status
                      ),
                      cons!CNAM_RAG_STATUS_LABELS[1],
                      if(
                        cons!APAC_SGP_RAG_STATUS_VALUES[3] = trim(
                          fv!row.rag_status
                        ),
                        cons!CNAM_RAG_STATUS_LABELS[2],
                        cons!CNAM_RAG_STATUS_LABELS[5]
                      )
                    )
                  ),
                  
                ),
                size: "GALLERY"
              ),
              align: "CENTER"
            )
          },
          pagingSaveInto: local!pagingInfo
        )
      }
    )
  }
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    This is the expected behavior based on how you have it set up.  As soon as you save your filter value into its local value, your query (rule!APAC_getEmailIntegrationCases()) will re-execute.  And by default, values from the filter boxes will save into their local variable upon unfocus, correlating to what you describe.

    There are various possibilities for keeping the old search results in the search box until "search" is clicked again.  One of my current favorite ways is to create duplicate sets of variables for all filters -- I tend to do i.e. "local!savedFilterValue" and "local!activeFilterValue" -- where the Query uses the "active" filter value(s), but the filter entry boxes save their values into the "saved" variables.  Then you would simply add an extra saveInto to your "Search" button to have the interface copy the "saved" values over to the "active" variables, and the query will re-execute only at that point, as is your current desire. 

    There's an added bonus in doing it this way, which is that it's then fairly easy to set up other variable(s) to monitor whether any changes have been made to the filter values since the last time "search" was pressed - one of the things you can do with this is, only enabling the "Search" button when there is a mismatch in at least one of the saved/active filter variable sets (meaning the user will need to press "Search" again to update the results).

Reply
  • 0
    Certified Lead Developer

    This is the expected behavior based on how you have it set up.  As soon as you save your filter value into its local value, your query (rule!APAC_getEmailIntegrationCases()) will re-execute.  And by default, values from the filter boxes will save into their local variable upon unfocus, correlating to what you describe.

    There are various possibilities for keeping the old search results in the search box until "search" is clicked again.  One of my current favorite ways is to create duplicate sets of variables for all filters -- I tend to do i.e. "local!savedFilterValue" and "local!activeFilterValue" -- where the Query uses the "active" filter value(s), but the filter entry boxes save their values into the "saved" variables.  Then you would simply add an extra saveInto to your "Search" button to have the interface copy the "saved" values over to the "active" variables, and the query will re-execute only at that point, as is your current desire. 

    There's an added bonus in doing it this way, which is that it's then fairly easy to set up other variable(s) to monitor whether any changes have been made to the filter values since the last time "search" was pressed - one of the things you can do with this is, only enabling the "Search" button when there is a mismatch in at least one of the saved/active filter variable sets (meaning the user will need to press "Search" again to update the results).

Children