Project

General

Profile

new field added with a plugin -> only displays in journal the ID

Added by Mario Primus over 9 years ago

issue_patch

belongs_to :responsible, :class_name => 'User', :foreign_key => 'responsible_id'
safe_attributes "responsible_id"

Everything works like expected but in Journal I only get
Responsible changed from 5 to 22 (... 5 and 22 are Ids)

What did I forget to get
Responsible change from UserName1 to Useranme2

Thanks.

journal.png (55.5 KB) journal.png Screenshot of Ticket with Journal

Replies (1)

RE: new field added with a plugin -> only displays in journal the ID - Added by Mario Primus over 9 years ago

Mario Primus wrote:

issue_patch

belongs_to :responsible, :class_name => 'User', :foreign_key => 'responsible_id'
safe_attributes "responsible_id"

Everything works like expected but in Journal I only get
Responsible changed from 5 to 22 (... 5 and 22 are Ids)

What did I forget to get
Responsible change from UserName1 to Useranme2

Thanks.

add a hook and change value and oldvalue from id to name

....
  module Hooks
    class HelpdersIssuesHook < Redmine::Hook::ViewListener
      def helper_issues_show_detail_after_setting(context={})
        if context[:detail].prop_key == "responsible_id" 
          context[:detail].value = Principal.find_by_id(context[:detail].value).try(:name)
          context[:detail].old_value = Principal.find_by_id(context[:detail].old_value).try(:name)
        end
...
....

    (1-1/1)