Leonidus
Leonidus

Reputation: 448

Populate a Dynamic Field Dropdown List in OTRS

I need to add a dropdown in the New Ticket Screen of OTRS. I managed to add a Dropdown by adding a Dynamic Field with the help of Dynamic Fields Management in Admin Section.
Now my problem is that I want to populate this Dropdown with data that I get from some distant database on the run and dependin on the User Loged In. How can i feed In this Dynamic Data in the DropDown List in OTRS ?

Thank you.

Upvotes: 4

Views: 3675

Answers (1)

joecop
joecop

Reputation: 935

To do such a thing I do not believe is supported from the Dynamic Field UI provided by OTRS.

So you can either:

1- add all the possible values into the drop down box and then hide/show them using code changes in the dtl file. (use javascript). For creating a new ticket there is either AgentTicketEmail.dtl or AgentTicketPhone.dtl. There is also the CustomerTicketMessage.dtl if you want to include it in the customer interface too.

2- Add only one value which you can also hide using javascript in the dtl files and just add values to the dropdown list using javascript code. Example javascript below hides/shows different dynamic fields. You can find what your dynamic field is called by looking at the page source from your browser.

function setdynamicviews(){     
        switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)

            case  "8\|\|Support": // need to slash escape the pipes                               
              //show dynamic fields          
              document.getElementById('LabelDynamicField_Product').style.display = 'block';                                  
              document.getElementById('LabelDynamicField_SerialNo').style.display = 'block';              
              break;        
         default:                                                             
               //hide dynamic fields.              
               document.getElementById('LabelDynamicField_Product').style.display = 'none';     
               document.getElementById('LabelDynamicField_SerialNo').style.display = 'none';              
        }   
    }   

To add items to usign javascript see here

Yuu have not provided enough information for me to help with getting the information "from some distant database"

Note: if you do change any DTL files or other otrs files you should defrinitely create a theme first see here

Hope this helps.

Upvotes: 1

Related Questions