When are changes to the dynamic fields updated in the csv search

Moderator: crythias

Post Reply
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

We have these dynamic fields they are included in the csv format.

What they are reporting now is that if a user after resolving a ticket if he search for the ticket and select export to CSV. And view the csv the value of the dynamic field like resolve time is not reflected.

I looked at the database, the time is saved. I looked at the dynamic fields names and id. There is nothing wrong with it. The system config looks correct still. Then after sometime when I did a search on the ticket again and export to csv I can see that the resolve time is present with the correct time.

I am not sure how to proceed. Do I need to do a 'COMMIT' when the time the ticket state is changed to resolved? I think mysql is auto-commit by default. The otrs is 3.3.2 and the os is Red Hat Linux Server release 6.3. I know the database is still mysql and not mariadb version is 5.1.61. It has a innodb log in my.cnf so I am guessing its using innodb.

When does otrs commit a change from web user gui the variables to database and when does a search for tickets being refreshed?
EXG133
Znuny expert
Posts: 217
Joined: 06 Aug 2012, 18:12
Znuny Version: 3.1.7 & 4.04

Re: When are changes to the dynamic fields updated in the csv search

Post by EXG133 »

You might have caching enabled for the report?
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

Re: When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

How do I check? I search the sysconfig for cache. And there are a lot configurations. I'm not certain which one is the cache for this reporting
EXG133
Znuny expert
Posts: 217
Joined: 06 Aug 2012, 18:12
Znuny Version: 3.1.7 & 4.04

Re: When are changes to the dynamic fields updated in the csv search

Post by EXG133 »

No not in the sysconfig, when you edit a statistic there's a dropdown on the first page:

Use cache: Yes / No
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

Re: When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

You mean the output of this ticket search is in a Statistics?
Image
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

Re: When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

I have three tickets that is very similar in issue now that I think caching may cause the issue on the other one. One at first gla nce looks like it was caused by the ACL since its reporting a wrong resolver group or there is a resolver group when the ticket is not yet resolved. I'm beginning to think that because my predecessor made the resolver group into a drop down dynamic field when the ticket is searched from the previous image and exported to csv. The first option/selection in the drop down is always shown.

The other is the resolve time is not showing up now it was previously that it always has the same time a the close time. I didn't understand my predecessor then why he put it in the ticket.pm with a state check that if its resolve or in progress or pending type state. It will keep on updating the resolved time. I think now it was his attempt to try and see if frequent update to the database will refresh the csv output.

He updates directly to the database by the way. So I did not touch his code and just put it back to the custom module he created.

I've even tried not accessing the database and update the ticket object itself. Did I make a mistake here:

This code is still in the custom module that a generic agent runs when the conditions are satisfied. Its not updating the ticket search output to csv at once it takes somewhere between 1 to 8 mins maybe more.

I saw a reply from RStub in a different topic not to directly update to the database because of caching issue and to use generic agent. Right now all the GenericAgent and ACLs are in the admin tools. They have a lot of policy on changes, which is why I am not sure if they will approve if I create a custom generic agent in a file or Kernel/Config/GenericAgent.pm. Is there a way to assign or set 'June 24, 2016 1:35 pm' in a dynamic field text file in GenericAgent GUI admin tool. Its an input text but I want to change what it input.
EXG133
Znuny expert
Posts: 217
Joined: 06 Aug 2012, 18:12
Znuny Version: 3.1.7 & 4.04

Re: When are changes to the dynamic fields updated in the csv search

Post by EXG133 »

Oh I misread sorry... Somehow thought you were talking about the CSV output of a report in the Statistics module.

Without knowing your setup I can't be sure, but you should always avoid writing directly to the DB. OTRS will cache dynamic fields in /opt/otrs/var/tmp/CacheFileStorable/. If you write to the DB this cache does not get updated.

In custom modules you can use DynamicFieldUpdate() ( http://otrs.perl-services.de/docs/otrs/ ... field.html ), that way you won't have caching issues.
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

Re: When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

Just to clarify I will need DynamicFieldGet(Name=>'ResolvedTime') something like that right? Then update using DynamicFieldUpdate() from the online document. If I understand correctly I will need to change the hash value inside Config right?

Can I asks where does LogObject->Dumper() output its data? I think I'll need to dump Config. To see how I'm going to update. I tried $Self{LogObject}->Dumper(%Ticket) couldn't see it in System logs. I'm also still a bit hazy where system logs are stored is it in var/log/message?
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

Re: When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

Did I make mistake in the object creation or what is objects are in a custom module. This is a custom module run by Generic Agent.

I keep getting an error that that the variable $DynamicField does not exists.

Image

Code: Select all


sub new {

    my ( $Type, %Param ) = @_;

    # all cate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    # check needed objects
    for (qw(DBObject ConfigObject LogObject MainObject TicketObject TimeObject EncodeObject)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }

    # 0=off; 1=on;
    $Self->{Debug} = $Param{Debug} || 0;

    return $Self;
}

sub Run {
    my ( $Self, %Param ) = @_;
        my $descr ="";
        my $TicketObject = $Self->{TicketObject};
        my %Ticket = $TicketObject->TicketGet(%Param,DynamicFields=>1);
        my $TicketID = $Ticket{'TicketID'};
        #my $Ticket_ResolvedTime = $Ticket{'DynamicField_ResolvedTime'};
        my $SystemTime = $Self->{TimeObject}->SystemTime();
        my $TimeStamp1 = $Self->{TimeObject}->SystemTime2TimeStamp(
        SystemTime => $SystemTime,
    );

    $Self->{LogObject}->Dumper(%Param);
    $Self->{LogObject}->Dumper(%Ticket);

    my $DynamicFieldObject = Kernel::System::DynamicField->new(
       ConfigObject        => $Self->{ConfigObject},
       EncodeObject        => $Self->{EncodeObject},
       LogObject           => $Self->{LogObject},
       MainObject          => $Self->{MainObject},
       DBObject            => $Self->{DBObject}
   );

    my $DynamicFieldValueObject = Kernel::System::DynamicFieldValue->new(
       ConfigObject        => $Self->{ConfigObject},
       EncodeObject        => $Self->{EncodeObject},
       LogObject           => $Self->{LogObject},
       MainObject          => $Self->{MainObject},
       DBObject            => $Self->{DBObject}
   );


   my $DynamicField = $DynamicFieldObject->DynamicFieldGet(
      Name => 'ResolvedTime'
   );

   $Self->{LogObject}->Log( Priority => 'notice', Message => 'Dynamic Field ID is '. $DynamicField{'ID'});
   $Self->{LogObject}->Log( Priority => 'notice', Message => 'Dynamic Field Name is '. $DynamicField{'Name'});

    my $Success = $DynamicFieldValueObject->ValueSet(
       FieldID  => $DynamicField{'ID'},
       ObjectID => $Ticket{'TicketID'},
       Value    => localtime($TimeStamp1)->strftime('%F %T'),
       UserID   => $Ticket{'OwnerID'}
    );

   $Self->{LogObject}->Log( Priority => 'notice', Message => 'Owner ID is '. $Ticket{OwnerID});
   $Self->{LogObject}->Log( Priority => 'notice', Message => 'Success is '. $Success);

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: When are changes to the dynamic fields updated in the csv search

Post by reneeb »

Whenever you want to access the DynamicField attributes, you have to add an '->'...

Code: Select all

$DynamicField->{Name}
instead of

Code: Select all

$DynamicField{Name}
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
OTRSRDNewbie
Znuny newbie
Posts: 69
Joined: 29 Apr 2016, 10:23
Znuny Version: 3.2, 5
Real Name: Dennis Cua
Company: N/A

Re: When are changes to the dynamic fields updated in the csv search

Post by OTRSRDNewbie »

I think I'm having problems with UserID now. I tried $Param{UserID}, $Ticket{'OwnerID'}. Both are blanks. I thinks thats whats keeping now the dynamic field from updating. Either that or I should have used DynamiField::BackEnd
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: When are changes to the dynamic fields updated in the csv search

Post by reneeb »

You should use the ::Backend module
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
Post Reply