Create a filter using Text Field

Hi ,

Actually , I have argent requirement that i need to create a filter using text field but I'm not able to archive ... 

here is my code  

load(
  local!fetch,
  local!pagingInfo:a!pagingInfo(
    startIndex:1, 
    batchSize: cons!batch_no, 
    sort:a!sortInfo( field:"projId", ascending:true())),
    
    
  
with(
  local!StudentsData:a!queryEntity(
  entity:cons!RQA_double_item_ENTITY, 
  query:a!query(
    filter:a!queryFilter(
      field:"field", 
      operator:"=", 
      value:ri!PorjectID
    ),
    pagingInfo:local!pagingInfo
    
  ),
  fetchTotalCount: true()
),
{
  a!sectionLayout(
      label: "Fetch Details",
      contents: {
        a!columnsLayout(
          columns: {
          a!columnLayout(
            contents: {
            
              a!textField(
                label: "Students ID",
                required: true(),
                value: local!fetch,
                saveInto: local!fetch
               
              ),
            a!buttonArrayLayout(
              buttons: {
                a!buttonWidget(
                  label: "Search",
                  value: local!fetch,
                  submit: true()
                  
                  
                )
              },
              align: "START"
            )
     
           } 
          ),
          }
        )
    }
    ),
a!sectionLayout(
      label: "Students Details",
      contents:{ 
if(rule!RQA_checkIsNullOrEmpty(local!StudentsData),
a!richTextDisplayField(label:"",value: "No Data Available"),
a!gridField(
  label: "",
 
  totalCount:local!StudentsData.totalCount,
  
  
  columns: {
    if(rf!requesttype=cons!RQA_VALUES[1],
    a!gridTextColumn(
      label: "Students ID",
      field: "student",
      data: index(local!StudentsData.data,"student",{}),
      alignment: "CENTER"
   ),{}),
   a!gridTextColumn(
     label: "ClassID",
     field: "classid",
     data: index(local!StudentsData.data,"classid",null),
     alignment: "CENTER"
     ),
   ...
   ..
   ..
   ...
   ..
   ..
   ..
       },
     value: local!pagingInfo,
      saveInto: local!pagingInfo,
      rowHeader: 1
          /*selection: true()*/
)
 )
},
isCollapsible:true())
}
)

)

  Discussion posts and replies are publicly visible

  • Hi 

    So you need to filter on two fields PorjectID and StudentId. for multiple filters you need to use a!queryLogicalExpression() in your query entity like 

    a!queryEntity(
    entity: cons!RQA_double_item_ENTITY,
    query: a!query(
    pagingInfo: local!pagingInfo,
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    field: "field",
    operator: "=",
    value: ri!PorjectID
    ),
    if(
    isnull(
    local!fetch
    ),
    {},
    a!queryFilter(
    field: "StudentId",
    operator: "=",
    value: local!fetch
    )
    )
    }
    )
    ),
    fetchTotalCount: true()
    )

  • 0
    Certified Lead Developer

    You are using the same variable local!fetch to save data for both - text field (Studen ID) as well as button(Search) click. And in filters you are using ri!PorjectID. So if my understanding is correct, you need to change the value and saveInto for text Field Students ID to ri!PorjectID. If ri!PorjectID is for some another purpose, consider creating a new variable that stores student ID data and add filter logic for that variable in the queryEntity() code.

    Hope it helps.

  • 0
    Certified Lead Developer
    in reply to Harsha Sharma

    Also, in the below code, make sure parameter 'field' is set to the field for which you want to filter data. I think it should be studentID field or some field related to this. Until, ofcourse "field" is the column name for student Id in your table, then its fine.

    a!queryFilter(
          field:"field", 
          operator:"=", 
          value:ri!PorjectID
        )