anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
178 stars 72 forks source link

get the last value and last update value in custom field #327

Open ashrafalzyoud opened 8 months ago

ashrafalzyoud commented 8 months ago

hi all thx for very important plugin

how i can get the last value of cfs[1] how i can get the last update value of cfs[1]

  self.custom_field_values = { 10=> CustomValue.where( custom_field_id: 1).last }
  self.custom_field_values = { 11=> CustomValue.where(custom_field_id: 1).update }
picman commented 8 months ago

1) CustomValue.where( custom_field_id: 1).last is perfectly fine. 2) What do you mean with 'last update value'? Custom values don't keep any time stamp just the value.

ashrafalzyoud commented 8 months ago

Table Name value A. 1 B. 2 C. 3 D. 4

The last value 4 If I need last change value

Name value A. 1 B. 6 // change value C. 3 D. 4

How I can know the last change value

picman commented 7 months ago

You would have to look into journal and _journaldetails tables to find out when was which custom value changed.

These two records correspond with a change of custom value (CF 22) of issue ID 94029.

MariaDB [redmine]> select * from journals order by created_on desc limit 1\G;

              id: 231500
  journalized_id: 94029
journalized_type: Issue
         user_id: 1935
           notes: 
      created_on: 2023-12-01 14:26:54
     updated_on: 2023-12-01 14:26:54
   updated_by_id: NULL
   private_notes: 0
1 row in set (0,001 sec)

ERROR: No query specified

MariaDB [redmine]> select * from journal_details where journal_id = 231500\G

        id: 352696
journal_id: 231500
  property: cf
  prop_key: 22
 old_value: 
     value: Nice to have