Related Data Not Showing up in Grid

I have two instances now where related data is not showing up in a read only and editable grid.  To solve this problem before, I had to create an Expression Rule to retrieve the data (not the record) for display purposes.  This is the latest example.

I have an editable grid that shows the positions for a specific clergy member. (the grid is not complete, I am just trying to get the data to display properly)  Relationships are built between Clergy Position and Clergy Member, Ref Clergy Position, and Parish.  All relationships are built both ways.  Data shows for the columns Term Start, Term End, Term and Term Complete.  Data does not show for columns Position, Organization and City; these are all related data.

 a!gridLayout(
            totalCount: count(local!clergyPositions),
            headerCells: {
              a!gridLayoutHeaderCell(label: "Position"),
              a!gridLayoutHeaderCell(label: "Organization"),
              a!gridLayoutHeaderCell(label: "City"),
              a!gridLayoutHeaderCell(label: "Term Start"),
              a!gridLayoutHeaderCell(label: "Term End"),
              a!gridLayoutHeaderCell(label: "Term"),
              a!gridLayoutHeaderCell(label: "Term Complete")
            },
            columnConfigs: {
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
              a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2)
            },
            rows: a!forEach(
              items: local!clergyPositions,
              expression: a!gridRowLayout(
                contents: {
                  a!textField(
                    label: "Position",
                    value: local!clergyPositions['recordType!CPMA Clergy Position.relationships.refPosition.fields.position']
                  ),
                  a!textField(
                    label: "Organization",
                    value: local!clergyPositions['recordType!CPMA Clergy Position.relationships.parish.fields.organizationname']
                  ),
                  a!textField(
                    label: "City",
                    value: local!clergyPositions['recordType!CPMA Clergy Position.relationships.parish.fields.organizationcity']
                  ),
                  a!dateField(
                    label: "Term Start",
                    value: local!clergyPositions['recordType!CPMA Clergy Position.fields.clergypositionstart']
                  ),
                  a!dateField(
                    label: "Term End",
                    value: local!clergyPositions['recordType!CPMA Clergy Position.fields.clergypositiontermend']
                  ),
                  a!floatingPointField(
                    label: "Term",
                    value: local!clergyPositions['recordType!CPMA Clergy Position.fields.assignmentterm']
                  ),
                  a!textField(
                    label: "Term Complete",
                    value: if(
                      local!clergyPositions['recordType!CPMA Clergy Position.fields.clergypositiontermend'] < today(),
                      "Yes",
                      "No"
                    )
                  )
                }
              )
            )
          )

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    I had to create an Expression Rule to retrieve the data

    Did you add the related record fields or the related record data to be queried in the expression rule. If I understand your question correctly, the solution to this would be adding those required related record fields in the query expression created.

    Querying related record fields

  • I have yet to read the link you sent, I will try and get to that today.  I do see where my original JSON did not include the fv!item, but it didn't seem to matter for the Non-related fields.

    Anyway, this is how I solved my problem.  Note the expression rules in each of the Related Data columns.  I am not sure I am doing the right thing especially if the user wants to be able to edit in the grid.

     a!gridLayout(
                totalCount: count(local!clergyPositions),
                headerCells: {
                  a!gridLayoutHeaderCell(label: "Position"),
                  a!gridLayoutHeaderCell(label: "Organization"),
                  a!gridLayoutHeaderCell(label: "City"),
                  a!gridLayoutHeaderCell(label: "Term Start"),
                  a!gridLayoutHeaderCell(label: "Term End"),
                  a!gridLayoutHeaderCell(label: "Term"),
                  a!gridLayoutHeaderCell(label: "Term Complete")
                },
                columnConfigs: {
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
                  a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2)
                },
                rows: a!forEach(
                  items: local!clergyPositions,
                  expression: a!gridRowLayout(
                    contents: {
                      a!textField(
                        label: "Position",
                        value: rule!CPMA_getRefPostionforClergyPositionId(fv!item['recordType!CPMA Clergy Position.fields.clergypositionId']),
                        readOnly: true
                      ),
                      a!textField(
                        label: "Organization",
                        value: rule!CPMA_getParishNameforClergyPositionId(fv!item['recordType!CPMA Clergy Position.fields.clergypositionId']),
                        readOnly: true
                      ),
                      a!textField(
                        label: "City",
                        value:  rule!CPMA_getParishCityforClergyPositionId(fv!item['recordType!CPMA Clergy Position.fields.clergypositionId']),
                        readOnly: true
                      ),
                      a!dateField(
                        label: "Term Start",
                        value: fv!item['recordType!CPMA Clergy Position.fields.clergypositionstart'],
                        readOnly: true
                      ),
                      a!dateField(
                        label: "Term End",
                        value: fv!item['recordType!CPMA Clergy Position.fields.clergypositiontermend'],
                        readOnly: true
                      ),
                      a!floatingPointField(
                        label: "Term",
                        value: fv!item['recordType!CPMA Clergy Position.fields.assignmentterm'],
                        readOnly: true
                      ),
                      a!textField(
                        label: "Term Complete",
                        value: if(
                          fv!item['recordType!CPMA Clergy Position.fields.clergypositiontermend'] < today(),
                          "Yes",
                          "No"
                        ),
                        readOnly: true
                      )
                    }
                  )
                )
              )

  • 0
    Certified Senior Developer
    in reply to Chris.Gillespie

    This will evaluate the query individually for each row. I would not recommend that. If you have rows somewhere around 1-50 you would not see much impact on the performance, but when you have large amounts of data, that would definitely impact the performance.

    I will suggest a better work around if you want it this way. You can query the related record data in a different local variable and use the a!displayValue() or the whereContains() to index and show the value.

    Also i see that all the fields are readOnly. Why not use the readOnly grid and use the a!recordData() which would solve all your problems. If you are going to have any additional fields as editable then please ignore this line.

Reply
  • 0
    Certified Senior Developer
    in reply to Chris.Gillespie

    This will evaluate the query individually for each row. I would not recommend that. If you have rows somewhere around 1-50 you would not see much impact on the performance, but when you have large amounts of data, that would definitely impact the performance.

    I will suggest a better work around if you want it this way. You can query the related record data in a different local variable and use the a!displayValue() or the whereContains() to index and show the value.

    Also i see that all the fields are readOnly. Why not use the readOnly grid and use the a!recordData() which would solve all your problems. If you are going to have any additional fields as editable then please ignore this line.

Children
No Data