Skip to main content
Inspiring
Sep 23, 2022 3:52 AM UTC
Question

Cannot sort by field because it is from a one-to-many record relationship.

I am getting this error "Cannot sort by field [teamMemberId] because it is from a one-to-many record relationship." when trying to apply sort field gridcoloumn

a!gridColumn(
label: "Members",
sortField:recordType!WFM RID.relationships.wfmRIDmember.fields.MemberId
value: count(
fv!row['recordType!WFM RID.relationships.wfmRIDmember.fields.MemberId']
)




7 replies

gabriele.camilli
Employee
Sep 23, 2022 7:50 AM UTC

Hi,

Which version of Appian are you on?

mikes0011
Brainy
Sep 23, 2022 1:02 PM UTC

The code you've shared doesn't logically work.  First your value is a count of "MemberId", implying that the value shown on a given cell in the grid will be the total number of MemberIds associated with the "wfmRIDmember" on that row.  I assume that would be fine, assuming that's what you want to be showing.

But then, what would sorting by "MemberId" even be expected to do?  Each row of your grid has its own set of MemberIds, for one thing, so sorting on those is not meaningful, let alone not possible.

In this case it's probably best to just not add a sort field to the grid column. Not all columns require sortability.

The Expression Guru
lavanyam0003
Known Participant
May 31, 2023 7:40 AM UTC

So, is there any other way to sort the field having one to many relationships.

stefanhelzle0001
Brainy
May 31, 2023 7:45 AM UTC

Mike gave a good answer to this question. Do you have a more specific question?