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.

This example uses the typical structure of OTRS/Znuny JS files. That way you don't need
$(document).readyor 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.