Dropdown fields not applying to query expression in \query record.

I have the following interface with 3 dropdowns.  When choices are selected in the dropdown boxes they do not apply to the query to filter out the grid display.

load(
  local!StatusLabels: {"Active","Inactive"},
  local!StatusValues: {"Active","Inactive"},
  local!SelectedStatus,
  local!StatusForFilter: "",
  local!SelectedPrefix,
  local!PrefixForFilter: "",
  local!SelectedPortfolio,
  local!PortfolioForFilter: "",
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20,
    sort: a!sortInfo(
      field: "RequestNumber",
      ascending: true
    )
  ),
a!dashboardLayout(
  firstColumnContents: {
    a!sectionLayout(
      label: "Parameter Selection",
      firstColumnContents: {
        a!dropdownField(
          Label: "Status",
          instructions: "Select A Status: " & local!StatusForFilter,
          choiceLabels: local!StatusLabels,
          placeholderLabel: "---Select Status ---",
          choiceValues:local!StatusValues,
          value: local!SelectedStatus,
          saveInto: local!StatusForFilter
          ),
          a!dropdownField(
          Label: "Request Prefix",
          instructions: "Please Select a Prefix: " & local!PrefixForFilter ,
          choiceLabels: cons!consGDRSPrefixChoiceLabels,
          placeholderLabel: "---Select Status ---",
          choiceValues: cons!consGDRSPrefixChoiceValues,
          value: local!SelectedPrefix,
          saveInto: local!PrefixForFilter
          ),    
          a!dropdownField(
          Label: "Request Portfolio",
          instructions: "Please Select a Portfolio " & local!PortfolioForFilter,
          choiceLabels: cons!consGDRSPorfolioChoiceLabels,
          placeholderLabel: "---Select Status ---",
          choiceValues: cons!consGDRSPortfolioChoiceValues,
          value: local!SelectedPortfolio,
          saveInto: local!PortfolioForFilter
          ),    
      }
    ),
    a!sectionLayout(
      label: "GDRS Records",
      firstColumnContents: {
  with(
    local!datasubset: queryrecord(
      cons!consGDRSRecordTypeforGrid,
      a!query(
        selection: a!querySelection(columns: {
          a!queryColumn(field: "Portfolio"),
          a!queryColumn(field: "RequestNumber"),
          a!queryColumn(field: "SubmitterRequester"),
          a!queryColumn(field: "ActiveInActive"),
          a!queryColumn(field: "ActualHoursWorked"),
          a!queryColumn(field: "ActualProductivityHoursSavedMonthlyGD"),
          a!queryColumn(field: "ActualProductivityHoursSavedMonthlyUPS"),
          a!queryColumn(field: "ControlType"),
          a!queryColumn(field: "ControlNumber"),
          a!queryColumn(field: "State"),
        }),
      logicialExpression:  a!queryLogicalExpression(
      Operator: "AND",
      filters: { a!queryFilter(
      field: "ActiveInActive",
      operator: "=",
      value: local!StatusForFilter
      ),
     a!queryFilter(
        field:  "RequestNumber",
        operator: "starts with",
        value: local!PrefixForFilter
      ),
      a!queryFilter(
        field:  "Portfolio",
        operator: "=",
        value: local!PortfolioForFilter
      )
      }
      ),
        pagingInfo: local!pagingInfo
      )
    ),
 
    a!gridField(
      totalCount: local!datasubset.totalCount,
      columns: {
        a!gridTextColumn(
          label: "Portfolio",
          field: "Portfolio",
          data: index(local!datasubset.data, "Portfolio", null)
        ),
        a!gridTextColumn(
          label: "Request Number",
          field: "RequestNumber",
          data: index(local!datasubset.data, "RequestNumber", null)
        ),
        a!gridTextColumn(
          label: "Requester",
          field: "SubmitterRequester",
          data: index(local!datasubset.data, "SubmitterRequester", null)
        ),
        a!gridTextColumn(
          label: "Status",
          field: "ActiveInActive",
          data: index(local!datasubset.data, "ActiveInActive", null)
        ),
        a!gridTextColumn(
          label: "Actual Hours Worked",
          field: "ActualHoursWorked",
          data: index(local!datasubset.data, "ActualHoursWorked", null)
        ),
        a!gridTextColumn(
          label: "Control Type",
          field: "ControlType",
          data: index(local!datasubset.data, "ControlType", null)
        ),
        a!gridTextColumn(
          label: "Control Number",
          field: "ControlNumber",
          data: index(local!datasubset.data, "ControlNumber", null),
          links: apply(
            a!recordLink(
              label: "Go to record view",
              recordType: cons!consRecordTypeForFeed,
              identifier: _,
              dashboard: "summary"
            ),
            local!datasubset.identifiers
          )
        ),
        a!gridTextColumn(
          label: "State",
          field: "State",
          data: index(local!datasubset.data, "State", null)
        )
      },
      value: local!pagingInfo,
      saveInto: local!pagingInfo
    )
  )
      },
secondColumnContents: {}
    )
  },
secondColumnContents: {}
)
)

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Does your dataSubset value change any when your filters are populated?  You can check this via a debug paragraph field as seen in the code i've enclosed.  Also, is there any reason you've put your with() there instead of surrounding the whole form, which is a more standard way of doing it?  Note that i would expect your way to still work, but just wondering.

    And just FYI, if you use the rich text editor, you can choose "insert" and then "code", and present your code in a way that doesn't overinflate your initial post, and preserves formatting.

     

    load(
      local!StatusLabels: {"Active","Inactive"},
      local!StatusValues: {"Active","Inactive"},
      local!SelectedStatus,
      local!StatusForFilter: "",
      local!SelectedPrefix,
      local!PrefixForFilter: "",
      local!SelectedPortfolio,
      local!PortfolioForFilter: "",
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20,
        sort: a!sortInfo(
          field: "RequestNumber",
          ascending: true
        )
      ),
      a!dashboardLayout(
        firstColumnContents: {
          a!sectionLayout(
            label: "Parameter Selection",
            firstColumnContents: {
              a!dropdownField(
                Label: "Status",
                instructions: "Select A Status: " & local!StatusForFilter,
                choiceLabels: local!StatusLabels,
                placeholderLabel: "---Select Status ---",
                choiceValues:local!StatusValues,
                value: local!SelectedStatus,
                saveInto: local!StatusForFilter
              ),
              a!dropdownField(
                Label: "Request Prefix",
                instructions: "Please Select a Prefix: " & local!PrefixForFilter ,
                choiceLabels: cons!consGDRSPrefixChoiceLabels,
                placeholderLabel: "---Select Status ---",
                choiceValues: cons!consGDRSPrefixChoiceValues,
                value: local!SelectedPrefix,
                saveInto: local!PrefixForFilter
              ),    
              a!dropdownField(
                Label: "Request Portfolio",
                instructions: "Please Select a Portfolio " & local!PortfolioForFilter,
                choiceLabels: cons!consGDRSPorfolioChoiceLabels,
                placeholderLabel: "---Select Status ---",
                choiceValues: cons!consGDRSPortfolioChoiceValues,
                value: local!SelectedPortfolio,
                saveInto: local!PortfolioForFilter
              ),    
            }
          ),
          a!sectionLayout(
            label: "GDRS Records",
            firstColumnContents: {
              with(
                local!datasubset: queryrecord(
                  cons!consGDRSRecordTypeforGrid,
                  a!query(
                    selection: a!querySelection(
                      columns: {
                        a!queryColumn(field: "Portfolio"),
                        a!queryColumn(field: "RequestNumber"),
                        a!queryColumn(field: "SubmitterRequester"),
                        a!queryColumn(field: "ActiveInActive"),
                        a!queryColumn(field: "ActualHoursWorked"),
                        a!queryColumn(field: "ActualProductivityHoursSavedMonthlyGD"),
                        a!queryColumn(field: "ActualProductivityHoursSavedMonthlyUPS"),
                        a!queryColumn(field: "ControlType"),
                        a!queryColumn(field: "ControlNumber"),
                        a!queryColumn(field: "State"),
                      }
                    ),
                    logicialExpression:  a!queryLogicalExpression(
                      Operator: "AND",
                      filters: {
                        a!queryFilter(
                          field: "ActiveInActive",
                          operator: "=",
                          value: local!StatusForFilter
                        ),
                        a!queryFilter(
                          field:  "RequestNumber",
                          operator: "starts with",
                          value: local!PrefixForFilter
                        ),
                        a!queryFilter(
                          field:  "Portfolio",
                          operator: "=",
                          value: local!PortfolioForFilter
                        )
                      }
                    ),
                    pagingInfo: local!pagingInfo
                  )
                ),
                {
                  a!paragraphField(
                    label: "DEBUG",
                    value: local!dataSubset,
                    instructions: "totalCount: " & local!dataSubset.totalCount,
                    readOnly: true()
                  ),
               
                  a!gridField(
                    totalCount: local!datasubset.totalCount,
                    columns: {
                      a!gridTextColumn(
                        label: "Portfolio",
                        field: "Portfolio",
                        data: index(local!datasubset.data, "Portfolio", null)
                      ),
                      a!gridTextColumn(
                        label: "Request Number",
                        field: "RequestNumber",
                        data: index(local!datasubset.data, "RequestNumber", null)
                      ),
                      a!gridTextColumn(
                        label: "Requester",
                        field: "SubmitterRequester",
                        data: index(local!datasubset.data, "SubmitterRequester", null)
                      ),
                      a!gridTextColumn(
                        label: "Status",
                        field: "ActiveInActive",
                        data: index(local!datasubset.data, "ActiveInActive", null)
                      ),
                      a!gridTextColumn(
                        label: "Actual Hours Worked",
                        field: "ActualHoursWorked",
                        data: index(local!datasubset.data, "ActualHoursWorked", null)
                      ),
                      a!gridTextColumn(
                        label: "Control Type",
                        field: "ControlType",
                        data: index(local!datasubset.data, "ControlType", null)
                      ),
                      a!gridTextColumn(
                        label: "Control Number",
                        field: "ControlNumber",
                        data: index(local!datasubset.data, "ControlNumber", null),
                        links: apply(
                          a!recordLink(
                            label: "Go to record view",
                            recordType: cons!consRecordTypeForFeed,
                            identifier: _,
                            dashboard: "summary"
                          ),
                          local!datasubset.identifiers
                        )
                      ),
                      a!gridTextColumn(
                        label: "State",
                        field: "State",
                        data: index(local!datasubset.data, "State", null)
                      )
                    },
                    value: local!pagingInfo,
                    saveInto: local!pagingInfo
                  )
                }
              )
            }
          )
        }
      )
    )

  • Hi Mike,
    I'm new to SAIL so if my with should be done differently I'm certainly willing to learn. I tried putting the debug in my code but I get an error as follows:
    Could not display interface. Please check definition and inputs.

    Interface Definition: Expression evaluation error at function 'with' [line 55]: A variable is incorrectly defined. Parameter: 2. Expected syntax: with(local!a, ..., expr) or with(local!a:10, ..., expr)
  • 0
    Certified Lead Developer
    in reply to pamelas216
    Apologies, I needed an extra set of brackets in my revised code since I added a paragraphField. I've edited the code block in my original reply, please try that instead.
  • Hi Mike,
    That did work with the brackets in it and no the number in the datasubset did not change. Does that mean the variables are not getting to the query?
  • 0
    Certified Lead Developer
    in reply to pamelas216

    Well first, let's try moving your with() declaration to the normal place (i.e. just inside the load() declaration).  I sorta thought it should work where you had it also, but just for the sake of ease please try this version and let me know if you experience anything different.

    load(
      local!StatusLabels: {"Active","Inactive"},
      local!StatusValues: {"Active","Inactive"},
      local!SelectedStatus,
      local!StatusForFilter: "",
      local!SelectedPrefix,
      local!PrefixForFilter: "",
      local!SelectedPortfolio,
      local!PortfolioForFilter: "",
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20,
        sort: a!sortInfo(
          field: "RequestNumber",
          ascending: true
        )
      ),
      
      
      with(
        local!datasubset: queryrecord(
          cons!consGDRSRecordTypeforGrid,
          a!query(
            selection: a!querySelection(
              columns: {
                a!queryColumn(field: "Portfolio"),
                a!queryColumn(field: "RequestNumber"),
                a!queryColumn(field: "SubmitterRequester"),
                a!queryColumn(field: "ActiveInActive"),
                a!queryColumn(field: "ActualHoursWorked"),
                a!queryColumn(field: "ActualProductivityHoursSavedMonthlyGD"),
                a!queryColumn(field: "ActualProductivityHoursSavedMonthlyUPS"),
                a!queryColumn(field: "ControlType"),
                a!queryColumn(field: "ControlNumber"),
                a!queryColumn(field: "State"),
              }
            ),
            logicialExpression:  a!queryLogicalExpression(
              Operator: "AND",
              filters: {
                a!queryFilter(
                  field: "ActiveInActive",
                  operator: "=",
                  value: local!StatusForFilter
                ),
                a!queryFilter(
                  field:  "RequestNumber",
                  operator: "starts with",
                  value: local!PrefixForFilter
                ),
                a!queryFilter(
                  field:  "Portfolio",
                  operator: "=",
                  value: local!PortfolioForFilter
                )
              }
            ),
            pagingInfo: local!pagingInfo
          )
        ),
        
        
        a!dashboardLayout(
          firstColumnContents: {
            a!sectionLayout(
              label: "Parameter Selection",
              firstColumnContents: {
                a!dropdownField(
                  Label: "Status",
                  instructions: "Select A Status: " & local!StatusForFilter,
                  choiceLabels: local!StatusLabels,
                  placeholderLabel: "---Select Status ---",
                  choiceValues:local!StatusValues,
                  value: local!SelectedStatus,
                  saveInto: local!StatusForFilter
                ),
                a!dropdownField(
                  Label: "Request Prefix",
                  instructions: "Please Select a Prefix: " & local!PrefixForFilter ,
                  choiceLabels: cons!consGDRSPrefixChoiceLabels,
                  placeholderLabel: "---Select Status ---",
                  choiceValues: cons!consGDRSPrefixChoiceValues,
                  value: local!SelectedPrefix,
                  saveInto: local!PrefixForFilter
                ),    
                a!dropdownField(
                  Label: "Request Portfolio",
                  instructions: "Please Select a Portfolio " & local!PortfolioForFilter,
                  choiceLabels: cons!consGDRSPorfolioChoiceLabels,
                  placeholderLabel: "---Select Status ---",
                  choiceValues: cons!consGDRSPortfolioChoiceValues,
                  value: local!SelectedPortfolio,
                  saveInto: local!PortfolioForFilter
                ),    
              }
            ),
            a!sectionLayout(
              label: "GDRS Records",
              firstColumnContents: {
                  
                a!paragraphField(
                  label: "DEBUG",
                  value: local!dataSubset,
                  instructions: "totalCount: " & local!dataSubset.totalCount,
                  readOnly: true()
                ),
             
                a!gridField(
                  totalCount: local!datasubset.totalCount,
                  columns: {
                    a!gridTextColumn(
                      label: "Portfolio",
                      field: "Portfolio",
                      data: index(local!datasubset.data, "Portfolio", {})
                    ),
                    a!gridTextColumn(
                      label: "Request Number",
                      field: "RequestNumber",
                      data: index(local!datasubset.data, "RequestNumber", {})
                    ),
                    a!gridTextColumn(
                      label: "Requester",
                      field: "SubmitterRequester",
                      data: index(local!datasubset.data, "SubmitterRequester", {})
                    ),
                    a!gridTextColumn(
                      label: "Status",
                      field: "ActiveInActive",
                      data: index(local!datasubset.data, "ActiveInActive", {})
                    ),
                    a!gridTextColumn(
                      label: "Actual Hours Worked",
                      field: "ActualHoursWorked",
                      data: index(local!datasubset.data, "ActualHoursWorked", {})
                    ),
                    a!gridTextColumn(
                      label: "Control Type",
                      field: "ControlType",
                      data: index(local!datasubset.data, "ControlType", {})
                    ),
                    a!gridTextColumn(
                      label: "Control Number",
                      field: "ControlNumber",
                      data: index(local!datasubset.data, "ControlNumber", {}),
                      links: apply(
                        a!recordLink(
                          label: "Go to record view",
                          recordType: cons!consRecordTypeForFeed,
                          identifier: _,
                          dashboard: "summary"
                        ),
                        local!datasubset.identifiers
                      )
                    ),
                    a!gridTextColumn(
                      label: "State",
                      field: "State",
                      data: index(local!datasubset.data, "State", {})
                    )
                  },
                  value: local!pagingInfo,
                  saveInto: local!pagingInfo
                )
              }
            )
          }
        )
      )
    )

     

    Edit: as an aside, I've replaced all of the instances of index(local!dataSubset.data, "fieldName", null) with index(local!dataSubset.data, "fieldName", {}).  The only difference this will make is, in my version if you use your filters to filter to zero rows of data, it won't break the grid like it will with the "null"s.

  •               /*  logicialExpression:  a!queryLogicalExpression(
                      Operator: "AND", */
                      filter: 
                        a!queryFilter(
                          field: "ActiveInActive",
                          operator: "=",
                          value: local!StatusForFilter
                      /*  ) ,
                        a!queryFilter(
                          field:  "RequestNumber",
                          operator: "starts with",
                          value: local!PrefixForFilter
                        ),
                        a!queryFilter(
                          field:  "Portfolio",
                          operator: "=",
                          value: local!PortfolioForFilter
                        )
                      } */
                    ),

    I'll try yours in just a minute.  I did make a change so that I was just sending one parameter and used a plain filter instead of a filter expression and it worked with just the one filter.  Now I'll try your code.

  • +1
    Certified Lead Developer
    in reply to pamelas216
    that raises a different point I should have mentioned - instead of relying on your complex queryRecord to work (with filters) in your SAIL form, try it out in an expression rule editor first and make sure it works fully as desired there (i suggest using rule inuts in place of the local variables, the effect should be the same). Optimally you might save an expression rule of your query and call that from your SAIL form, especially if there's chance you would want to do the same query on other forms / in other places of your application. It also makes debugging a lot easier.
  • It still doesn't apply the 3 filters into the query expression.
  • +1
    Certified Lead Developer
    in reply to pamelas216

    I just noticed you have this typo in your query expression:

    logicialExpression

    (should be "logicalExpression")

     

    [hence my suggestion to get the query working externally before use on your form and/or as an early debugging step ;-)]