How to use JSON to fill a text field?

Hi all, We are still using OTRS 3.0. I want to fill TicketFreeText5 (a text field) with the phone number of the building selected in TicketFreeText6 (a select with all our possible locations). In AgentTicketPhone.dtl, I’ve added (after dtl:block:TicketFreeText): <!--dtl:js_on_document_complete--> <script type="text/javascript">//<![CDATA[ $('#TicketFreeText6').bind('change', function (Event) { Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'BuildingAJAXUpdate', 'TicketFreeText6', ['TicketFreeText5']); }); //]]></script> <!--dtl:js_on_document_complete--> In AgentTicketPhone.pm, I’ve added the Subaction 'BuildingAJAXUpdate'. It succesfully retrieves the phone number of the building, but fails when it has to response the AJAX call. I’ve tried two ways: - First, I tried using Layout->JSONEncode: $JSONContent = $Self->{LayoutObject}->JSONEncode( Data => { TicketFreeText5 => $BuildingData{Phone}, } ); - Second, I tried using Layout->BuildSelectionJSON (it isn’t a select field, but I’ve seen it used in such cases [although can’t remember where]): $JSONContent = $Self->{LayoutObject}->BuildSelectionJSON( [ { Name => 'TicketFreeText5', Data => $BuildingData{Phone}, SelectedID => $BuildingData{Phone}, }, ] ); Either way, the JSON string sent was {"TicketFreeText5":"3"}, being 3 the phone number. So I though everything was ok, but the web broser showed ‘TicketFreeText5’ instead of ‘3’ in the text field. Anybody can help me to correctly fill a text field using AJAX? Kind regards, Juan Clavero
participants (1)
-
Juan Manuel Clavero Almirón