Skip to main content
andred0523
September 5, 2024
Solved

How to highlight changes in read only grid

  • September 5, 2024
  • 7 replies
  • 0 views

Hello, I have a doubt and I am unsure how to proceed.

 

I have an interface where the individual record rows are displayed in a read only grid where I am using the FK of another table to filter and display only those audits for a specific record.

The requirement is to display a different background color in the read only grid of the values in the row based on previous entries. For example

 

FKID Name Temp Approved
1 Tim 20 No
1 Timmy 22 Pending
1 Timmy 22 Yes
1 Timmy 23 Retired

Timmy, 22 and pending are highlighted in the second row because they differ from the first entry.

Yes is highlighted in the third entry due to being different than pending.

23 and retired are highlighted because they differ from previous also.

I have a record query as below and I feel I need to compare the fv!row[currentValue] against the indexed local data somehow but I am not sure how to proceed.

a!localVariables(
  local!data: a!queryRecordType(
    recordType: 'ADtable',
    fields: {},
    filters: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        a!queryFilter(
          field: 'recordType!aDtable.fields.ForiegnKeyID',
          operator: "=",
          value: ri!recordID 
        )
      },
      ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 1000)
  ).data,
GRID INFO....
            a!gridColumn(
          label: "Name",
          sortField: fv!row['recordType!ADtable.fields.['Name'],
          value: fv!row['recordType!ADtable.fields.{'Name'],
          backgroundColor: index(
            contains(local!data['recordType!ADtable.fields.['Name'],fv!row['recordType!ADtable.fields.['Name']),
            "#FFD260",
            null()
          )
        ),



  )
)

Best answer by somasundaram.d

[mention:1c8729d486d54456ae61e2ca1389dcc7:e9ed411860ed4f2ba0265705b8793d05] 

Can you try the following code, attached the output too

{
  a!gridField(
    label: "Read-only Grid",
    labelPosition: "ABOVE",
    data: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record',
    columns: {
      a!gridColumn(
        label: "Column Text 1",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1',
        backgroundColor: a!localVariables(
          local!prevDataToCompare:index(
            fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1'],
            if(
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))=1,
              1,
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))-1
            ),
            null
          ),
          if(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1']=local!prevDataToCompare,"","SUCCESS")
        ),
        value: a!linkField(
          links: {
            a!recordLink(
              label: fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1'],
              recordType: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record',
              identifier: fv!identifier
            )
          }
        )
      ),
      a!gridColumn(
        label: "Column Text 2",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2',
        value: fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2'],
        backgroundColor: a!localVariables(
          local!prevDataToCompare:index(
            fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2'],
            if(
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))=1,
              1,
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))-1
            ),
            null
          ),
          if(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2']=local!prevDataToCompare,"","SUCCESS")
        )
      ),
      a!gridColumn(
        label: "Column Int 1",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1',
        value: fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1'],
        align: "END",
        backgroundColor: a!localVariables(
          local!prevDataToCompare:index(
            fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1'],
            if(
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))=1,
              1,
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))-1
            ),
            null
          ),
          if(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1']=local!prevDataToCompare,"","SUCCESS")
        )
      ),
      a!gridColumn(
        label: "Created On",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn',
        value: if(
        isnull(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn']),
        fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn'],
        datetext(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn'], "default")
        ),
        align: "END"
      )
    },
    validations: {},
    refreshAfter: "RECORD_ACTION",
    showSearchBox: true,
    showRefreshButton: true
  )
}

7 replies

kumara0180
September 5, 2024

Can be achieved. May be track customrecord field in Record which would tell you if particular column data has changed and use that to change the color of the entry.

You would need one custom record field to track per column.

somasundaram.d
September 6, 2024

[mention:1c8729d486d54456ae61e2ca1389dcc7:e9ed411860ed4f2ba0265705b8793d05] 

Can you try the following code, attached the output too

{
  a!gridField(
    label: "Read-only Grid",
    labelPosition: "ABOVE",
    data: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record',
    columns: {
      a!gridColumn(
        label: "Column Text 1",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1',
        backgroundColor: a!localVariables(
          local!prevDataToCompare:index(
            fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1'],
            if(
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))=1,
              1,
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))-1
            ),
            null
          ),
          if(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1']=local!prevDataToCompare,"","SUCCESS")
        ),
        value: a!linkField(
          links: {
            a!recordLink(
              label: fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{8fee16c5-bc87-4d33-a46b-e1c39b25f6e9}columnText1'],
              recordType: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record',
              identifier: fv!identifier
            )
          }
        )
      ),
      a!gridColumn(
        label: "Column Text 2",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2',
        value: fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2'],
        backgroundColor: a!localVariables(
          local!prevDataToCompare:index(
            fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2'],
            if(
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))=1,
              1,
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))-1
            ),
            null
          ),
          if(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{717a1a55-f027-4e7f-839e-f2b0d3952243}columnText2']=local!prevDataToCompare,"","SUCCESS")
        )
      ),
      a!gridColumn(
        label: "Column Int 1",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1',
        value: fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1'],
        align: "END",
        backgroundColor: a!localVariables(
          local!prevDataToCompare:index(
            fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1'],
            if(
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))=1,
              1,
              cast(1,wherecontains(
                fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id'],
                fv!currentPage.data['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{242f2a8c-169a-4345-948b-aa61bf515adf}id']
              ))-1
            ),
            null
          ),
          if(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{34d06097-eaf6-437b-8e69-00708b9075f1}columnInt1']=local!prevDataToCompare,"","SUCCESS")
        )
      ),
      a!gridColumn(
        label: "Created On",
        sortField: 'recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn',
        value: if(
        isnull(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn']),
        fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn'],
        datetext(fv!row['recordType!{485cddfe-74bb-4111-9761-ced23336d3d0}SSD Test Record.fields.{143ce626-9b78-4401-9b3d-38bce3d99370}createdOn'], "default")
        ),
        align: "END"
      )
    },
    validations: {},
    refreshAfter: "RECORD_ACTION",
    showSearchBox: true,
    showRefreshButton: true
  )
}

andred0523
September 6, 2024

Thank you, this solution worked for me.

This was the first time I have seen the fv!currentPage used as there's not much information on it outside of the one mention in the docs and  [mention:6b9f80ff18f9420082d13ef2d5121d56:e9ed411860ed4f2ba0265705b8793d05] mentioning it in the community

peter.lewis
Employee
September 6, 2024

Yeah it's actually a pretty neat feature! I'll see if we can get a bit more documentation to talk about it more :)

stefanhelzle0001
September 6, 2024

That's not a simple task. If you want to do this at runtime inside an interface, you would have to query the data first. Then Iterate on each individual field and create a data structure that holds the data about what has changed. Then you can feed that into the grip.

kumara0180
September 6, 2024

[mention:a11f77a729fb4db2af76b09948583328:e9ed411860ed4f2ba0265705b8793d05] You are right and I was thinking about this how to make it simple. 
here is an idea. If it is business critical, I would add one column in Audit table to track which columns has changed and use that to highlight which columns has changed 

stefanhelzle0001
September 6, 2024

Yeah, that could work. Give it a try.