# Bug AGILE-383 - Display deleted custom field journals in the Project activities

Project: Stream agile
Status: confirmed
URL: https://community.openproject.org/work_packages/AGILE-383

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 18.0.0 |
| Observed in versions |  |
| Sprint | Sprint 14 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers | OP Dev Polaris Team |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Effort (shirt size) |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  Set up a project attribute and enable it inside a project.

2.  Set a value for the project attribute

3.  Delete the project attribute in the system settings.

4.  Go to the Project Activities page and enable filtering by "Project details"

5.  Look for the journal where the value is set for the deleted project attribute.

### What is the buggy behavior?

  - The journal displays `"_The changes were retracted."_`

### What is the expected behavior?

1.  The journal should display `**(deleted custom field)** set to _12312345_`.

### Technical details

The [`JournalChanges#get_custom_field_changes`](https://github.com/opf/openproject/blob/a2fb66452d46165e3de4d870860a14673be2a4a3/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb#L101-L102) ([Source code](https://github.com/opf/openproject/blob/a2fb66452d46165e3de4d870860a14673be2a4a3/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb#L101-L102)) method joins the project attribute mapping table in order to decide which values to display. Since a deleted field doesn't have the mapping anymore, the deleted field journal entries are being filtered out. One possible solution is to check if the journal field is deleted besides the mapping:

``` ruby
relation = relation.with(cf_mappings: journable.project_custom_field_project_mappings)
                   .joins("LEFT OUTER JOIN cf_mappings USING (custom_field_id)")
                   .where(
                     "cf_mappings.custom_field_id IS NOT NULL OR NOT EXISTS " \
                     "(SELECT 1 FROM custom_fields WHERE custom_fields.id = customizable_journals.custom_field_id)")
```
