Hi everyone, first post in the Community.I have a default filter on a record type:
a!queryFilter( field: "createdBy", operator: "=", value: loggedInUser(), applyWhen: not( isusermemberofgroup(loggedInUser(), cons!MY_ADMINISTRATOR_GROUP) ) )
The idea is that administrators can view all entries, while regular users can only view entries that they have created.Filter works fine in the record grid view, but breaks the Summary view upon clicking on a record, with the following error:
An error occurred while retrieving the data for “MY_DATATYPE”. Details: Unexpected error executing query (type: [...], query: [Report on Record Type], order by: [[Sort[id asc]]], filters:[((id = TypedValue[it=1,v=1]) AND null)]) (APNX-1-4205-003)
It is evident that the issue is due to the use of the applyWhen parameter (remove it and the problem disappears), but I can't figure out why.So, questions:
1) What is the cause of the problem?2) How can I fix it?3) Is there a better why to achieve what I'm trying to do?
Thanks in advance.
Discussion posts and replies are publicly visible
Try with If condition instead of applywhen.
Why? And how would I do that? The filter expression editor asks for a queryFilter.
As per my understanding the issue is with applywhen when you use only one queryfilter as it is returning a null value instead of empty filter {} when the applywhen is false.
For a workaround you can use the if condition as below.
if( isusermemberofgroup( loggedInUser(), cons!MY_ADMINISTRATOR_GROUP ), {}, a!queryFilter( field: "createdBy", operator: "=", value: loggedInUser() ))
Or you can use queryLogicalExpression function as below
a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter(field: "createdBy",operator: "=",value: loggedInUser() applyWhen: not( isusermemberofgroup( loggedInUser(), cons!MY_ADMINISTRATOR_GROUP ) ) ) })
Thank you, very clear explanation. The problem is now solved and I understand the cause.
Good catch venky uppala - this didn't occur to me perhaps since just that query filter was posted in the original code snippet, I didn't notice the context of it being the only filter (which i've dealt with before but in other contexts).