Hey all,
I have an email notification sent every time a record is changed. This is great. But I would like to highlight, bold, or announce the column that was changed. E.g. if I have the columns orderid, status, product, and a user changes the product entry, I would like the notification to say โUSEREMAIL() updated the product column from Product A to Product B at NOW()โ. Now, in reality, I have 10 columns, some of which have child records.
My current approach is:
<<If: [_THISROW_BEFORE].[Status] <>[_THISROW].[Status]>>
<<USEREMAIL()>> changed status from <<[_THISROW_BEFORE].[Status]>> to <<[_THISROW].[Status]>>
<<EndIf>>
The issue is: I donโt want to copy and paste this for every column and I donโt want to change it every time I update a column name or add a column.
Is there something built in to do this? (ideal) if not, is there a way to iterate through every column automatically?
No.
No. And I canโt think of an easy way to loop through X number of Columns.
But you might be able to use List-Subtraction to get a list of values that are new.
LIST(
[_THISROW_AFTER].[Column1],
[_THISROW_AFTER].[Column2],
[_THISROW_AFTER].[Column3],...
)
-
LIST(
[_THISROW_BEFORE].[Column1],
[_THISROW_BEFORE].[Column2],
[_THISROW_BEFORE].[Column3],...
)
So itโs only going to be useful if you can make it obvious which column those values are from.
I know thatโs not ideal. But itโs the simplest solution I can think of to easily see what changed.
Then if you really want to get creative, you could try to format the values in the After list that are not in the before list.
That could work! Could you offer syntax or advice on this approach? I know how to print column by column, but how does one print a full row? How does one compare a full before row to a full after row and format on differences?
There isnโt a way to print a full row with a single expression. You would have to list out each column name, with the before and after values each in their own expression.
Column | Before | After |
---|---|---|
Col1 | <<[_THISROW_BEFORE].[Col1]>> | <<[_THISROW_AFTER].[Col1]>> |
Col2 | <<[_THISROW_BEFORE].[Col2]>> | <<[_THISROW_AFTER].[Col2]>> |
Then, if you want the after value to be red when the value has changed, you could replace the after column with IF() statements.
<<IF(
[_THISROW_BEFORE].[Col1] <> [_THISROW_AFTER].[Col1],
[_THISROW_AFTER].[Col1], <<-format this part RED in the template
[_THISROW_AFTER].[Col1]
)>>
The expression returns the same data in either case, but you can format each one differently.
This table format in a google doc works FABULOUSLY and simply. Thank you!
User | Count |
---|---|
44 | |
29 | |
23 | |
20 | |
15 |