Add a dynamic field in the search result (CSV)

Moderator: crythias

Locked
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Add a dynamic field in the search result (CSV)

Post by girishmungra »

How can I add a dynamic field in the search result (CSV) for an Agent Ticket Search?

In sysconfig i went there:
Ticket -> Frontend::Agent::Ticket::ViewSearch
Ticket::Frontend::AgentTicketSearch###SearchCSVData

and added

DynamicField_field12 in the list.

didn't work..
thanks for help
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add a dynamic field in the search result (CSV)

Post by crythias »

look a little lower on the page.

The appropriate code (Kernel/Modules/AgentTicketSearch.pm) :

Code: Select all

                    # include the selected dynamic fields on CVS resutls
                    DYNAMICFIELD:
                    for my $DynamicFieldConfig ( @{ $Self->{CSVDynamicField} } ) {
                        next DYNAMICFIELD if !IsHashRefWithData($DynamicFieldConfig);
                        next DYNAMICFIELD if !$DynamicFieldConfig->{Name};
                        next DYNAMICFIELD if $DynamicFieldConfig->{Name} eq '';

                        push @CSVHead, 'DynamicField_' . $DynamicFieldConfig->{Name};
                    }
                }
That seems interesting ... there must be a CSVDynamicField config...
Sure enough, it's the last entry on the page.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Re: Add a dynamic field in the search result (CSV)

Post by girishmungra »

hi

from the code i deduce that field I should add in the config should start with 'DynamicField_ '. And this exactly what I did at first but doesn't work :(

Code: Select all

 my @Data;
                for (@CSVHead) {

                    # check if header is a dynamic field and get the value from dynamic field
                    # backend
                    if ( $_ =~ m{\A DynamicField_ ( [a-zA-Z\d]+ ) \z}xms ) {

                        # loop over the dynamic fields configured for CSV output
                        DYNAMICFIELD:
                        for my $DynamicFieldConfig ( @{ $Self->{CSVDynamicField} } ) {
                            next DYNAMICFIELD if !IsHashRefWithData($DynamicFieldConfig);
                            next DYNAMICFIELD if !$DynamicFieldConfig->{Name};

                            # skip all fields that does not match with current field name ($1)
                            # with out the 'DynamicField_' prefix
                            next DYNAMICFIELD if $DynamicFieldConfig->{Name} ne $1;

                            # get the value as for print (to corretly display)
                            my $ValueStrg = $Self->{BackendObject}->DisplayValueRender(
                                DynamicFieldConfig => $DynamicFieldConfig,
                                Value              => $Info{$_},
                                HTMLOutput         => 0,
                                LayoutObject       => $Self->{LayoutObject},
                            );
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add a dynamic field in the search result (CSV)

Post by crythias »

girishmungra wrote:from the code i deduce that field I should add in the config should start with 'DynamicField_ '
How did you deduce that? The code push @CSVHead, 'DynamicField_' . $DynamicFieldConfig->{Name}; adds DynamicField_ to the entries in the CSV section at the bottom of the Config page.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Re: Add a dynamic field in the search result (CSV)

Post by girishmungra »

Looks like I still haven't seen how to add my dynamic field in Ticket::Frontend::AgentTicketSearch###SearchCSVData
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add a dynamic field in the search result (CSV)

Post by crythias »

Click the (+).
Type your field name in key. (This should be the name without DynamicField_)
add 1 to "content"

this will make it export.

To search on it, do the same thing for
Ticket::Frontend::AgentTicketSearch###DynamicField
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

Re: Add a dynamic field in the search result (CSV)

Post by girishmungra »

But there is no 'content' column in Ticket::Frontend::AgentTicketSearch###SearchCSVData
Its just a list of data to export in CSV format.
I tried without the DynamicFiled_ but doesn't work.
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add a dynamic field in the search result (CSV)

Post by crythias »

Ticket - FrontendAgentTicketViewSearch - SysConfig - Admin - OTRS - Googl_2012-09-06_08-08-50.png
What do you see on your screen?
You do not have the required permissions to view the files attached to this post.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
girishmungra
Znuny newbie
Posts: 59
Joined: 24 Jul 2012, 18:20
Znuny Version: 3.1.7
Real Name: Girish Mungra

[SOLVED] Re: Add a dynamic field in the search result (CSV)

Post by girishmungra »

I am a plum! didn't notice that config.
Many thanks - was able to export my dynamic fields
OTRS 3.1.7 on Linux RedHat with MySQL database connected to an Active Directory for Agents and Customers.
serwert
Znuny newbie
Posts: 8
Joined: 17 Nov 2014, 14:06
Znuny Version: 3.1.11
Real Name: Seweryn
Company: Concordia

Re: Add a dynamic field in the search result (CSV)

Post by serwert »

Hi,
I have similar problem but only with non-text type dynamic fields.
In csv I always get the empty columny (for e.g. drop down list).
Do you know some resolution for this problem?
Thanks for help!
Best regards
Locked