Dynamic Operators & Fields on query record.

I have a requirement where the user can select the 5 mutliple dropdown values,Sort for any one of 5 and operators for each value from operator dropdown and Gate operator (AND or OR).

Ex:
Employee Dept(dropdown) Sort On(radio button) Operator(dropdown) Gate
Medical Yes = AND
Transport No is null OR
Finance No includes AND
Billing No = OR
Delivery No in AND

based on the user selected values I would required a query record with selected employee depts as fields in the filters with respective operators.

Can someone please provide your valuable suggestions to write queryrecord.

Thanks in Advance.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    I do not really understand the logic you want to implement. Maybe you explain it in more detail.

  • Sorry for the confusion I have attached the ss for your reference.

    Now if I choose 5 employee depts on each dropdown and only one sort on , 5operators & 5 And/Or and passing these values into ruleinput using a CDT.

    Now this rule input I will pass into queryRecordType where the 5 employee depts will act the field in queryFilter.

    Example query: 
    a!queryRecordType(
    recordType: EMployeeDataRecord,
    filters: a!queryLogicalExpression(
    operator: "OR",
    logicalExpressions: {
    a!forEach(
    items: ri!EmployeeCriteria,
    expression: a!queryLogicalExpression(
    operator: fv!item.gate,
    filters: a!queryFilter(
    field: fv!item.employeeDept,
    operator: fv!item.operator,
    value: if(
    or(
    rule!APN_isEmpty(tointeger(fv!item.value)),
    rule!APN_isBlank(fv!item.value)
    ),
    "NA",
    if(
    cleanwith(fv!item.value, "0123456789") = fv!item.value,
    tointeger(fv!item.value),
    fv!item.value,

    )
    )
    )
    )
    ),

    },
    ignoreFiltersWithEmptyValues: true
    ),
    )

    The sample Structure of the CDT will be 


    local!defaultData: {
    {
    id: null,
    employeeDept: "Medical",
    sortOn: null,
    operator: "=",
    gate: "AND",
    value:7
    },
    {
    id: null,
    employeeDept: "Transport ",
    sortOn: null,
    operator: "is null",
    gate: "OR",
    value:"Testing"
    },
    {
    id: null,
    employeeDept: "Finance",
    sortOn: null,
    operator: "includes",
    gate: "AND",
    value:null
    },
    {
    id: null,
    employeeDept: "Billing",
    sortOn: null,
    operator: "=",
    gate: "AND",
    value:3
    },

    {
    id: null,
    employeeDept: "Delivery",
    sortOn: null,
    operator: "in",
    gate: "AND",
    value: "d"
    },


    },

  • 0
    Certified Lead Developer
    in reply to hemap0003

    You need to replace employeeDept in your dictionary with a record field reference (i.e. recordType.recordField) instead of a text value.