Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
Show/Hide dropdown based on another option in OTRS

Im trying to create a .js (similar to Core.Agent.Znuny4OTRSShowPendingTimeIfNeeded.js), which the main function is show/enable specific dynamicField dropdown when a specific option are selected in Next State dropdown. All of this, for now, only affect ATPending action. This is my try so far:

$(document).ready(function() {
            setTimeout(function() {
                    const Action = Core.Config.Get("Action");
                    const SupportedActions = ["AgentTicketPending"];

                    if ($.inArray(Action, SupportedActions) !== -1) {
                        if (Action === "AgentTicketPending")
                        document.getElementsByClassName("Row Row_DynamicField_ApproverList")[0].style.visibility = "hidden";
                        $('#NewStateID').on('change', function() {
                                const Option = $(this).val();
                                if (Option === 'pending approval') {
                                    document.getElementsByClassName("Row Row_DynamicField_ApproverList")[0].style.visibility = "visible";
                                } else if (Option !== 'pending approval') {
                                    document.getElementsByClassName("Row Row_DynamicField_ApproverList")[0].style.visibility = "hidden";
                                }
                            }
                        );
                    }
                });
            });

Resume: When "pending approval" state is selected, DF "Approver" is visible. enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This example uses the typical structure of OTRS/Znuny JS files. That way you don't need $(document).ready or a timeout. I suppose you also create your own xml file to load this JS globally. You should use the IDs for the state if you want to support more languages, i used StateID 4 (open) here. Hope that helps.

"use strict";

var Core = Core || {};
Core.Agent = Core.Agent || {};

/**
 * @namespace Core.Agent.HideField
 * @memberof Core.Agent
 * @description
 *      This namespace contains the functions for handling Agent.HideField.
 */
Core.Agent.HideField = (function (TargetNS) {

    /**
     * @name Init
     * @memberof Core.Agent.HideField
     * @function
     * @description
     *      Initializes the module functionality.
     */
    TargetNS.Init = function () {

        const SupportedActions = ["AgentTicketPending"];
        const Action = Core.Config.Get("Action");

        if ($.inArray( Action, SupportedActions) !== -1) {

            $('#NewStateID').on('change', function() {
                if (Action === "AgentTicketPending") {
                    // use:
                    // $("#NewStateID").children("option").filter(":selected").text()
                    // to get the text of the selected option

                    if ( $('#NewStateID').val() == "4" ) {
                        // hide dynamic field
                        $('.Row.Row_DynamicField_ApproverList').hide();
                    }else{
                        // show dynamic field
                        $('.Row.Row_DynamicField_ApproverList').show();
                    }
                }
            });
        }

    };

    Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE');

    return TargetNS;
}(Core.Agent.HideField || {}));
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda