Skip to main content
March 4, 2024
Question

count() and length() is not working with related record

  • March 4, 2024
  • 9 replies
  • 0 views

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.

9 replies

srmm0001
March 4, 2024

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

)

March 5, 2024

I tried forcing refresh as well but still the issue is same.

harshitb6843
March 5, 2024

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?

March 14, 2024

 [mention:b8ea18cfbb2e4f6d841cf3c1d4d7420b:e9ed411860ed4f2ba0265705b8793d05] 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

stefanhelzle0001
Brainy
March 5, 2024

I did a quick test using the following code, and it works as expected, returning 4.