SQL query on DropDown dynamic fields

Moderator: crythias

Locked
srenon
Znuny newbie
Posts: 60
Joined: 20 Mar 2013, 14:26
Znuny Version: 3.3.8

SQL query on DropDown dynamic fields

Post by srenon »

Hello,

I want to extract by SQL the value given by a dynamic dropdown field. I saw that the value, is stored in the dynamic_field table in the field config which is a longblob.

How to extract the text value of the list (selected by the user when the ticket is created) using the key of the dropdown field stored in dynamic_field_value.value_text.

Thanks for your help
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: SQL query on DropDown dynamic fields

Post by crythias »

You want the result as attached to a ticket or an article or the list that belongs to a dynamic field?
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
srenon
Znuny newbie
Posts: 60
Joined: 20 Mar 2013, 14:26
Znuny Version: 3.3.8

Re: SQL query on DropDown dynamic fields

Post by srenon »

Easier,

How to have the two red circle items with SQL
Click on the picture to see it full size.
Image

knowing that "Théme abordé" comes from a dropdown dynamic field
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: SQL query on DropDown dynamic fields

Post by crythias »

Let me ask the question again:
Do you want:
1) The result of the filled field
or
2) The list the field presents?
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
srenon
Znuny newbie
Posts: 60
Joined: 20 Mar 2013, 14:26
Znuny Version: 3.3.8

Re: SQL query on DropDown dynamic fields

Post by srenon »

The result of the filled field given by

Code: Select all

SELECT ticket.*, dynamic_field.name, dynamic_field.label, dynamic_field_value.value_text from tickets left join dynamic_field_value on (dynamic_field_value.object_id=ticket.id) left join dynamic_field on (dynamic_field_value.field_id = dynamic_field.id AND dynamic_field.object_type = "Ticket")
Gives the index key of the string that was selected in the dropdown list, but not the selected string.

The list presented in the field is stored as longblob in dynamic_field.config

For example consider a dropdown containing list of colors

key | value
01 | yellow
02| red
03 | blue

how make a query which return ticket number and the color, not the key of the color?.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: SQL query on DropDown dynamic fields

Post by crythias »

srenon wrote:Gives the index key of the string that was selected in the dropdown list, but not the selected string.
so make the key equal to the string.
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
srenon
Znuny newbie
Posts: 60
Joined: 20 Mar 2013, 14:26
Znuny Version: 3.3.8

Re: SQL query on DropDown dynamic fields

Post by srenon »

actually works!

Thanks
pushreply
Znuny newbie
Posts: 14
Joined: 17 Apr 2013, 16:32
Znuny Version: 3.2.4
Real Name: Pu Shrep

Re: SQL query on DropDown dynamic fields

Post by pushreply »

Hi, could you help me:
let's say, I have this SQL Query:

1.

Code: Select all

SELECT ticket.*, dynamic_field.name, dynamic_field.label, dynamic_field_value.value_text from ticket left join dynamic_field_value on (dynamic_field_value.object_id=ticket.id) left join dynamic_field on (dynamic_field_value.field_id = dynamic_field.id) where dynamic_field.object_type="Ticket" and curdate() = date_add(date(ticket.create_time), interval 7 day);
2. I have a dynamic value: "Ticket1WeekOverdue" as Dropdown

How to display the query result (as a list in the dropdown)?
I'm using OTRS 3.2.4 - mysql (in Win 7)

Thank you!
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: SQL query on DropDown dynamic fields

Post by crythias »

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
Locked