Last modification date dynamic field

Moderator: crythias

Locked
napster
Znuny newbie
Posts: 9
Joined: 13 Jan 2014, 17:34
Znuny Version: 3.3.3
Real Name: Kevin Loos
Company: Axentys

Last modification date dynamic field

Post by napster »

Hi,

I would like to have a last modification date/time for dynamic fields.

I add a column in dynamic_field_value table named last_modification_time (datetime type)

I add this piece of code in DynamicFieldValue.pm

Code: Select all

	
my $ValueLastDate = strftime "%F %H:%M:%S", localtime;

    for my $Value (@Values) {

        # create a new value entry
        return if !$Self->{DBObject}->Do(
            SQL =>
                'INSERT INTO dynamic_field_value (field_id, object_id, value_text, value_date, value_int, last_modification_time)'
                . ' VALUES (?, ?, ?, ?, ?, ?)',
            Bind => [
                \$Param{FieldID}, \$Param{ObjectID},
                \$Value->{ValueText}, \$Value->{ValueDateTime}, \$Value->{ValueInt}, \$ValueLastDate 
            ],
        );
    }
But it doesn't work :( Could someone help me ?

Thanks !

PS : OTRS 3.3.3 Windows installation and MySql database
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Last modification date dynamic field

Post by reneeb »

napster wrote:But it doesn't work :(
This isn't an appropriate error message ;-)

Are there any log messages? What happens when you update a value?

On the other side, you could use the ticket history to get the needed information...
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
napster
Znuny newbie
Posts: 9
Joined: 13 Jan 2014, 17:34
Znuny Version: 3.3.3
Real Name: Kevin Loos
Company: Axentys

Re: Last modification date dynamic field

Post by napster »

There is no error. I think that my modification in the code aren't take into account.

Nothings happens when I update a value

Should I recompile the code ? If I have to, how can I do that ?

Sorry but i know absolutely nothing about Perl.

Thanks :)
napster
Znuny newbie
Posts: 9
Joined: 13 Jan 2014, 17:34
Znuny Version: 3.3.3
Real Name: Kevin Loos
Company: Axentys

Re: Last modification date dynamic field

Post by napster »

I found the solution.

I use current_timestamp as the value for my last modification_date

It might seem that you have to wait for OTRS to take the modifications into account.

My code if someone else need this function :

Code: Select all

# create a new value entry
            SQL =>
        return if !$Self->{DBObject}->Do(
                'INSERT INTO dynamic_field_value (field_id, object_id, value_text, value_date, value_int, last_modification)'
                . ' VALUES (?, ?, ?, ?, ?, current_timestamp)',
            Bind => [
                \$Param{FieldID}, \$Param{ObjectID},
                \$Value->{ValueText}, \$Value->{ValueDateTime}, \$Value->{ValueInt},
            ],
			
        );
Locked