Skip to main content
August 18, 2023
Question

Dynamic Operators & Fields on query record.

  • August 18, 2023
  • 3 replies
  • 0 views

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.

[mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05]

[mention:2773a0b2dec7409a8eee377b9fc57b88:e9ed411860ed4f2ba0265705b8793d05]

[mention:6b9f80ff18f9420082d13ef2d5121d56:e9ed411860ed4f2ba0265705b8793d05]

[mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05]

3 replies

stefanhelzle0001
Brainy
August 18, 2023

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

hemap0003Author
August 18, 2023

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"
},


},

mathieud0001
Brainy
August 18, 2023

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