Hello,I'm trying to create an expression inside my recordtype, but it doesn't work for me.I must always filter by a field that is equal to a value (ProductType = "N") This field is a CDT value that the record pulls from. Before I had it as By Field and it worked well for me.But now I need that the same field can have two values "1234" or "2221", this value is not in the CDT of the record, it is inside a related field of the main CDT.In short, I need my record to always have TypeProduct = "N" (it belongs to CDT Product = Product.TipoProduct) and Client = "1234" or Client = "2221", (being client = Product.Customer.Client)I'm trying it with queryLogicalExpression, but it doesn't work for me.
Thank you very much for your reply.
Discussion posts and replies are publicly visible
What does your expression look like now? If you share the code then perhaps we can help.
HI Stewart
a!queryLogicalExpression( operator: "AND", logicalExpressions: { a!queryLogicalExpression( operator: "AND", filters: a!queryFilter( field: rf!TipoProduct, operator: "=", value: "NS") ), a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter(field: rf!idPortfolio.IdClient.commercial, operator: "=", value: user(loggedInUser(),"customField2")), a!queryFilter(field: rf!idPortfolio.IdClient.asistente, operator: "=", value: user(loggedInUser(),"customField2")) } ) } )
The CDT of the record is Product that has a TypeProduct field and also a CDT type idPortfolio field that has idPortfolio.IdClient.commercial
Thanks a lot
Are you using this in your default filters? If yes, then I think one of the issues is that you are not referencing the fields correctly. In the default filter, you reference the field using a string instead of rf!, so you would need something like this:
a!queryLogicalExpression( operator: "AND", logicalExpressions: { a!queryLogicalExpression( operator: "AND", filters: a!queryFilter( field: "TipoProduct", operator: "=", value: "NS") ), a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter(field: "idPortfolio.IdClient.commercial", operator: "=", value: user(loggedInUser(),"customField2")), a!queryFilter(field: "idPortfolio.IdClient.asistente", operator: "=", value: user(loggedInUser(),"customField2")) } ) } )
If this still doesn't work, you may also need to check the type of the relationship used between the Product CDT and the idPortfolio CDT. I believe you can only use a nested CDT as a filter if the relationship is a 1:1 or M:1 relationship. If you're using another relationship type, you may want to create a database view and apply these filters directly to the DB view.
Hi Peter,
I had also done it as you indicate, but I get the following error "the field [TipoProduct] does not exist. (APNX-1-4203-000)" and that that field is a field directly from the record entity.
The relationship is 1:1
Summarizing the only thing that I need is that Product Type has the value N the commercial the value user(loggedInUser(),"customField2") and the assistant user(loggedInUser(),"customField2"), where a value will never necessarily coexist in the commercial or in the assistant, and can be null.Actually I do not care to filter on the Record with expression than with by Filed.
I have in by Field ProductType = N and it good
Then in Expression:
a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter(field: "idPortfolio.IdClient.commercial", operator: "=", value: user(loggedInUser(),"customField2")), a!queryFilter(field: "idPortfolio.IdClient.asistente", operator: "=", value: user(loggedInUser(),"customField2")) })
The field [idPortfolio.IdClient.commercial] does not exist. (APNX-1-4203-000)
Thanks for your help.