I have a parent record case details which is having a one to many relationship with another record task details. When the data of caseDetails is loaded on first load of interface in rule input or local variable either using query record or process model, then I'm using count() or length() function to count no. of items in related record "task details" which is populating in relationship of caseDetails in same rule input or local variable.
Count or length both are returning count as 1 only. But, if I make any changes in loaded tasks list and it's updated on any user action then count is showing correct count of items in that relationship.
Discussion posts and replies are publicly visible
Hi,
Force a Refresh
Query Entity:
When using a!queryEntity to load data, add a new parameter a!refreshVariable() as input to force Appian to fetch new data.
Process model:
If the data comes from a process model, use the "Refresh Variable" option in the relevant node's properties.
Save the Parent:
Trigger a save of the parent record after any changes to the related records. This updates the parent's data and should invalidate the cache
Example of a!queryEntity:
Code:
a!queryEntity(
entity: cons!Your_Parent_Record_CDT,
consolidated: true,
identifiers: a!pagingInfo(),
a!refreshVariable() // Force a fresh fetch of related records
)
I tried forcing refresh as well but still the issue is same.
I guess it is because of the structure of the data. Can you try adding a screenshot of the variable value and the block of code where you have used these functions? Also, did you try using the flatten() function?
!!!ATTENTION!!! This post and the example code is not correct. Please ignore it!
I did a quick test using the following code, and it works as expected, returning 4.
Thank you for sharing your solution idea!
Not sure what you mean. Your code snippet has the following issues at least:
- There is no parameter "consolidated" and "identifiers"
- You pass the paging info to the parameter "identifiers"
- You pass a refreshVariable into the query, which is just wrong.
But, maybe it is just me ....
Maybe this answer is straight from chatGPT, without verifying.
Harshit Bumb (Appyzie) You are right. The problem was with the structure of record data. Somewhere in the code the related record structure was updating. This is fixed now. Thanks