Hi All,
I am getting the error if multiple matches exist for the filter criteria. Below given is the code. Can anyone please help me out?
a!queryEntity( entity: cons!TEMS_ENTITY_V_TE_DETAILS, query: a!query( paginginfo: a!pagingInfo(1, - 1), logicalexpression: a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter( field: "cafNumber", operator: "=", value: tostring(local!selectedCaf) ) } ) ), fetchTotalCount: true ).data
Discussion posts and replies are publicly visible
Hi shubhamy,
1.) please try this function for inserting code.
This makes the life of your content reader way easier.
2.) What is the error telling you, can you insert as well?what is the overall use case? Often its not an issue of your query and more of the usage of the query.
3.)
shubhamy0001 said: a!queryLogicalExpression( operator: "OR", filters: { a!queryFilter( field: "cafNumber", operator: "=", value: tostring(local!selectedCaf) ) } )
a) why are you using "OR"?
b) why are you using querylogialexpression and not just the "filter" parameter of your query if you are looking for just one value in your DB?
c.) is "local!selectedCaf" multiple?
Hi Richard,
I am getting the following error:
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!textField [line 1606]: Invalid index: Cannot index property 'permittedTeRange' of type String into type List of Variant.
Yes, local!selectedCaf can be multiple in dropdown but user will select only one.
Hi, can try type casting the data type to the required CDT type.
It sounds like your returned data set is empty based on that error message. First I would suggest updating the a!textField()'s value parameter to is the property() function as:
property(local!data,"permittedTeRange",null)
this is a typical message if the your variable is NULL but not really Null-savetry to use index( local!selectedCaf,"permittedTeRange",null) instead of local!selectedCaf.permittedTeRange.
second idea: are the selecatable choicevalues all of the same type or do you have strings and numbers.... mixed up?
Hi,
I have a similar problem while working on an interface. The interface works fine without using any local variables but I want to learn using local variables in applications.
I want to display a summary view of assets. When I use local variable, I am getting the following error:
Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!formLayout [line 4]: Invalid index: Cannot index property 'partId' of type Text into type DataSubset.a!localVariables( local!asset:rule!BC_QE_GetVAsset(partid: ri!asset.partId,isHazardous: 1), a!formLayout( label: "Summary of" & " " & "Asset" & " " & local!asset.partId Query Rule a!queryEntity( entity: cons!BC_DSE_V_ASSET, query: a!query( logicalexpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "partId", operator: "=", value: ri!partId ), a!queryFilter( field: "isHazardous", operator: "=", value: ri!isHazardous ) }, ignorefilterswithemptyvalues: true ), paginginfo: a!pagingInfo( startIndex: 1, batchSize: 50 ), ) )
a!localVariables( local!asset:rule!BC_QE_GetVAsset(partid: ri!asset.partId,isHazardous: 1), a!formLayout( label: "Summary of" & " " & "Asset" & " " & local!asset.partId Query Rule a!queryEntity( entity: cons!BC_DSE_V_ASSET, query: a!query( logicalexpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "partId", operator: "=", value: ri!partId ), a!queryFilter( field: "isHazardous", operator: "=", value: ri!isHazardous ) }, ignorefilterswithemptyvalues: true ), paginginfo: a!pagingInfo( startIndex: 1, batchSize: 50 ), ) )
I tried fixing by using the index function. But not retrieving the value in the form. label: "Summary of" & " " & "Asset" & " " & index(local!asset,"partId",null),
label: "Summary of" & " " & "Asset" & " " & index(local!asset,"partId",null),
It should display as below:
This worked bcos I used ri!asset.partId.
Please advice how to fix the problem?
And, if this works for Part Id , then Should I use index or property function for all other fields in the interface? or I can fix this in my query rule?
TIA.
Hi Sandhya, Use below modified local variable and then it should work.
local!asset:index(rule!BC_QE_GetVAsset(partid: ri!asset.partId,isHazardous: 1),"data",{})
Unknown said:local!asset:index(rule!BC_QE_GetVAsset
Assuming the rule runs a Query Entity operation, it's almost always safe to just write ".data" at the end of the rule call in cases like this since even if the rule returns empty, it'll still contain a .data property (also empty).
local!asset: rule!BC_QE_GetVAsset( partid: ri!asset.partId, isHazardous: 1 ).data,
(also for getting dot properties, I still think it's cleaner code and easier to understand later, if we use "property()" to get a property, and reserve "index()" for getting an index. but of course i know 75% of the people here have already decided they don't care about this )
HI Mike and Gopal,
I tried both the methods but still showing the same error.
Hi Sandhya , make sure your query output is not null. It should have valid data.
Please share your current version of the top 4 lines of code. Here's what I think you would need to have currently for it to work (and not give the error message even when the query results in an empty return set):
a!localVariables( local!asset: rule!BC_QE_GetVAsset( partid: ri!asset.partId, isHazardous: 1 ).data, a!formLayout( label: "Summary of Asset" & " " & property(local!asset, "partId", "[no matches found]"),
Hi Mike,
Your coding worked. But facing another issue now. I am getting an error for the quantity field now. So I should be using property function for all the remaining fields?
alVariables( local!asset:rule!BC_QE_GetVAsset(partid: ri!asset.partId,isHazardous: 1).data, a!formLayout( contents: { a!richTextDisplayField( value: { a!richTextItem( text: ( "Summary of" & " " & "Asset" & " " & property(local!asset, "partId", null), ), color: "ACCENT", size: "MEDIUM_PLUS", style: "STRONG" ) } ), a!boxLayout( label: "This asset is no longer available", showWhen: local!asset.quantity = 0, style: "#cc0000", marginBelow: "STANDARD" ),
Thanks