Solved

display ticket field to certain companies

  • 17 April 2024
  • 3 replies
  • 40 views

Badge +3

with the help of this thread

 

I figured out how to hide an entire ticket field from all customer companies except customer 1. How do I go about only showing the ticket field for a few customers? like company 1 and company 6

 

Also this hides the drop down but does not hide the field label. Does anyone know how to remove the label as well?

 

<script type="text/javascript">
{% if portal.user.company_name <> "company 1")) %}
document.addEventListener("DOMContentLoaded", function() {
jQuery('#helpdesk_ticket_custom_field_cf_affected_geo_3014498').remove();
});
{% endif %}
</script>
icon

Best answer by acn084 25 April 2024, 20:27

View original

3 replies

Userlevel 7
Badge +12

Hi.

Your best option would be to use Dynamic fields.

https://support.freshdesk.com/en/support/solutions/articles/212889-creating-dynamic-sections

 

Regards,

Badge +3

updated the submit ticket portal and I was able to do this with a javascript case scripting. if company is c1,c2,c3 do nothing Else remove the custom drop down . I have not figured out how to hide the field label yet.

 

https://support.freshdesk.com/en/support/solutions/articles/65037-conditional-statements

 

<script type="text/javascript">
{% case portal.user.company_name %}
{% when 'C1' %}
{% when 'C2' %}
{% when 'C3' %}
{% else %}
    document.addEventListener("DOMContentLoaded", function() {
          jQuery('#helpdesk_ticket_custom_field_cf_affected_geo_3014498').remove();
    })
{% endcase %}
</script>

 

Badge +3

The above code still kept the header but removed the field from the list. I’ve updated it to use the following and now it removes the entire form label from code. 

 

    document.addEventListener("DOMContentLoaded", function() {
        jQuery(document).ready(function($) {
        $('.form-label[for="helpdesk_ticket_custom_field_cf_affected_geo_3014498"]').closest('.form-group').remove();
    }); 

Reply