DynamicField Dropdown/Ticket Add Value

Moderator: crythias

Post Reply
Volverine87
Znuny newbie
Posts: 40
Joined: 14 Nov 2017, 15:19
Znuny Version: OTRS 5.0.20
Real Name: Rafal
Company: UKWSL

DynamicField Dropdown/Ticket Add Value

Post by Volverine87 »

Hi Everyone,

I would like to add a big list to my DynamicField named ContractorName, but I thou adding it 1 by 1 will take long time specially if I got around 400 of them.
I tried to located table in MySQL but I didn't find Value table only ID fieldID and objectID, not actual name?
Tried to search for it using grep on Ubuntu searching for "DynamicField_ContractorName" but there was no luck apart from this location:
/opt/otrs/var/tmp/CacheFileStorable/DynamicField/3/a/3a185f32828a79653f6a091eb41d040c matches

but I didn't have permission to open CacheFileStorable while I was log as root, I guess only OTRS user have access to file there, but I'm concern why it is in Temp folder?
I would like to copy and paste whole contractor list from excel or other table and drop it to specific dynamic field. then generate key value from 1 till 400...
Is this possible?
Or I should book couple of hours to manually add them.
Many thanks
You do not have the required permissions to view the files attached to this post.
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: DynamicField Dropdown/Ticket Add Value

Post by reneeb »

See OPAR module ImportExportDynamicFields. This includes a script to import values for specific dynamic fields....
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
Volverine87
Znuny newbie
Posts: 40
Joined: 14 Nov 2017, 15:19
Znuny Version: OTRS 5.0.20
Real Name: Rafal
Company: UKWSL

Re: DynamicField Dropdown/Ticket Add Value

Post by Volverine87 »

Thanks "Reneeb"

For an advice, I installed package on test version 5.0.26, but I don't see additional functions to import/export on my screen, seems package been installed properly, should I do it from console? or web interface? if console what would be command?
Thanks
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: DynamicField Dropdown/Ticket Add Value

Post by reneeb »

Code: Select all

perl bin/otrs.Console.pl Maint::DynamicFields::ImportValues --file your.csv --name dynamicFieldName
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
Volverine87
Znuny newbie
Posts: 40
Joined: 14 Nov 2017, 15:19
Znuny Version: OTRS 5.0.20
Real Name: Rafal
Company: UKWSL

Re: DynamicField Dropdown/Ticket Add Value

Post by Volverine87 »

Thanks for the info!
I played around with the code, I did export to file, export all DynamicField or just specific all works well, csv file look bit messy when opened but I guess it does the job so cant complain, I added couple extra line as a test key 6 key 7 and key 8, saved it and when tried to importvalues I received below error:

otrs@ih-otrs-02-test:/home/otrs-test-administrator$ /opt/otrs/bin/otrs.Console.pl Maint::DynamicFields::ImportValues --file /tmp/dynamic_field2.csv --name ContractorName
Import values for dropdown dynamic field...
ERROR: OTRS-otrs.Console.pl-Maint::DynamicFields::ImportValues-10 Perl: 5.22.1 OS: linux Time: Fri Apr 20 11:54:46 2018

Message: Failed to parse CSV line 1 (input: "[{""Valid"":""valid""","Config:""---\nDefaultValue: ''\nLink: ''\nLinkPreview: ''\nPossibleNone: '1'\nPossibleValues:\n '1': Boom\n '12': Bomb Man\n '2': BinMan\n '4': Batman Man\n '5': Superman\n '6': Flash\n '7': Joker\n '8': Harley Queen\nTranslatableValues: '0'\nTreeView: '1'\n""","FieldType:""Dropdown""","Name:""ContractorName""","ObjectType:""Ticket""","FieldOrder:""3""","Label:""Contractor Name""}]"
, error: EIQ - QUO character not allowed)

Traceback (34386):
Module: Kernel::System::CSV::CSV2Array Line: 277
Module: Kernel::System::Console::Command::Maint::DynamicFields::ImportValues::Run Line: 63
Module: (eval) Line: 460
Module: Kernel::System::Console::BaseCommand::Execute Line: 454
Module: Kernel::System::Console::InterfaceConsole::Run Line: 86
Module: /opt/otrs/bin/otrs.Console.pl Line: 38

What happened now instead of having selection of 8 dropdown now I lost them all.

Any suggestion what I might did wrong?

Thanks

Edit 1.

I tried it again with same information but I exported it as .json not.csv added extra field and then imported as .json and its work! So I'm happy I can complete task but they question still stay same, why csv fail? If anyone know the answer will be great.
Thanks !
Last edited by Volverine87 on 20 Apr 2018, 16:55, edited 1 time in total.
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: DynamicField Dropdown/Ticket Add Value

Post by reneeb »

What does the .csv looks like?
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
Volverine87
Znuny newbie
Posts: 40
Joined: 14 Nov 2017, 15:19
Znuny Version: OTRS 5.0.20
Real Name: Rafal
Company: UKWSL

Re: DynamicField Dropdown/Ticket Add Value

Post by Volverine87 »

[{"Valid":"valid" Config:"---\nDefaultValue: ''\nLink: ''\nLinkPreview: ''\nPossibleNone: '1'\nPossibleValues:\n '1': Boom\n '12': Bomb Man\n '2': BinMan\n '4': Batman Man\n '5': Superman\n '6': Flash\n '7': Joker\n '8': Harley Queen\nTranslatableValues: '0'\nTreeView: '1'\n" FieldType:"Dropdown" Name:"ContractorName" ObjectType:"Ticket" FieldOrder:"3" Label:"Contractor Name"}]

its splitted in 7 columns A-G
not sure how I should post it here as attachment not accept .csv here
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: DynamicField Dropdown/Ticket Add Value

Post by reneeb »

Your CSV should look like:

Code: Select all

1;"Boom"
12;"Bomb Man"
2;"BinMan"
4;"Batman Man"
5;"Superman"
6;"Flash"
7;"Joker"
8;"Harley Queen"
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