Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2691 - On logging detail civireport show words instead of numbers (part 2) #20907

Merged
merged 1 commit into from
Aug 13, 2021

Conversation

demeritcowboy
Copy link
Contributor

Overview

https://lab.civicrm.org/dev/core/-/issues/2691

This is a followup to #20844 which only addressed activity record type. This addresses foreign keys, displaying more useful words instead of the foreign key id, e.g. fk activity_id => activity subject or fk contact_id => display_name.

  1. Turn on logging at admin - system settings - misc
  2. Do something like edit an activity.
  3. Go to the Contact Logging Summary report.
  4. Drill down on the detail for that change. (Note for activities it will usually say action = Delete, because at the moment the report is only showing activity_contact records not activity records, and civi often does a delete+insert to make an update. I'm only mentioning this because you might be looking for the word Update in the report and not seeing it, but that's separate from making numbers into words.)

Before

Something like this

Untitled

After

Something like this:

Untitled2

Technical Details

There's metadata available that says if a field is a foreign key and then on the foreign class there's metadata that tells you what would be meaningful to display as a label for that record. So this looks up that label. I'm not sure if there's already an api4 function available that takes a table+field and gets it for you.

For the test I had to work around something that only comes up in tests where logging will always have the same connection id throughout the entire run, whereas in real life on different page requests there'll be a different connection id corresponding to each change. The logging detail report relies on the connection id to tell what db records were associated with a change, so if I don't artificially fiddle with it then it thinks everything that has happened since the start is all one big change.

Comments

@civibot
Copy link

civibot bot commented Jul 20, 2021

(Standard links)

@civibot civibot bot added the master label Jul 20, 2021
@eileenmcnaughton
Copy link
Contributor

OK - this seems fine - I think you have an interest in this report @sluc23

It does work as it says - and getFieldValue has caching.

My one concern that I have not yet verified is whether the string is adequately escaped on the template

@eileenmcnaughton
Copy link
Contributor

This doesn't change things re my concern so I'll merge & consider that elsewhere

@eileenmcnaughton eileenmcnaughton merged commit 93a26a3 into civicrm:master Aug 13, 2021
@demeritcowboy demeritcowboy deleted the report-entitylabel branch August 14, 2021 14:06
@demeritcowboy
Copy link
Contributor Author

Word!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants