Skip to main content
chrisg0006
April 1, 2025
Solved

What you see is not what you get. Download does not match screen.

  • April 1, 2025
  • 10 replies
  • 0 views

I have an odd problem.  I have a read only grid what shows a value one way on the interface, but differently in the excel download.

Here is what you see in the interface vs the excel spreadsheet.

Here is the offending code in the Grid.

a!gridColumn(
 label: "Residential Status",
 value: rule!CMS_GetCurrentResidentialStatusId(fv!row['recordType!CMS Clergy Member Status Report.fields.clergyId'])
),

Here is the expression rule.

a!localVariables(
  /*
   * Get list of current resendential type addresses for clergy member
   * ordered by start date
   */
  local!residentialAddressData: a!queryEntity(
    entity: cons!CMS_ADDRESS_CLERGY_ASSIGNED_ADDRESS,
    query: a!query(
      selection: a!querySelection(
        columns: {
          a!queryColumn(
            field: "clergyAddress.residentialStatus.status"
          )
        }
      ),
      logicalExpression: a!queryLogicalExpression(
        operator: "AND",
        logicalExpressions: {
          a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "clergyId",
                operator: "=",
                value: ri!clergyMemberId
              ),
              a!queryFilter(
                field: "clergyAddress.addressType.addressType",
                operator: "in",
                value: { "Home", "Rectory" }
              ),
              a!queryFilter(
                field: "clergyAddressStart",
                operator: "<=",
                value: todate(now())
              )
            }
          ),
          a!queryLogicalExpression(
            operator: "OR",
            filters: {
              a!queryFilter(
                field: "clergyAddressEnd",
                operator: "is null"
              ),
              a!queryFilter(
                field: "clergyAddressEnd",
                operator: ">",
                value: todate(now())
              )
            }
          )
        }
      ),
      pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: - 1,
        sort: a!sortInfo(
          field: "clergyAddressStart",
          ascending: false
        )
      )
    )
  ).data,
  if(
    count(local!residentialAddressData) > 0,
    local!residentialAddressData[1].clergyAddress.residentialStatus.status,
    null
  )
)

Here is what the expression rule returns.

Best answer by mikes0011

Is there a way to do that when the value is held in a CDT-based table?  After playing with it for a few minutes it seems like the answer is still "no".

a custom record field

10 replies

mikes0011
Brainy
April 1, 2025

What method are you using to generate the Excel?  What is the configuration?

chrisg0006
April 1, 2025

I'm using the built in export function.  That part of the grid, "showExportButton: true".

mikes0011
Brainy
April 1, 2025

Your grid column is using a rule to (presumably) look up and display the text value for the ID being returned by your data set.  I don't think this is expected to be automatically handled in the "export" functionality just because it's configured in an on-form grid column.  (I have barely used the built-in "export grid" button for this and other reasons, so I'm fuzzy on what hacks may or may not be available to us here.)

Are you not able to create a plaintext Record column based on the relationship with whatever table contains the values tied to those IDs?

stefanhelzle0001
April 1, 2025

I detected an antipattern: Querying in a Loop

 [mention:0c6e36f2a6b948ddb06cc7d8d358406e:6b577b8c04704e209d29b6772bf67243] 

Did you consider a custom record field to directly hold that value?

mikes0011
mikes0011Answer
Brainy
April 1, 2025

Is there a way to do that when the value is held in a CDT-based table?  After playing with it for a few minutes it seems like the answer is still "no".

a custom record field
stefanhelzle0001
April 1, 2025

Correct. But it still is a problematic design decision worth pointing out.

 [mention:47f656218bd54913aefbdc1e97de975f:e9ed411860ed4f2ba0265705b8793d05] , did you try to add a tostring() to line 67 in your expression? It seems like it returns a text wrapped into an any type. That Excel export might not like that.