Hidden fields and Conditional fields on "New Ticket" page in Portal

Hi everyone,

I need to input a variable values for fields that are not displayed to the requester when submitting a form on the “New Ticket” page in the Portal.

Currently, while editing the page, I only see the {% snippet new_ticket_form %} with all the fields previously set up and I haven’t been able to find the individual placeholder tags for the all of the fields we have set up - default and custom.

It would be ideal to set a value for the “Subject” field with information selected by the requester in the form from the “Type” field and another Custom Field we have.

Also, would it possible to make a field be displayed on a conditional basis, depending on the requesters selections from previous fields, without relying on the “dynamic sections” of the Field Manager? Dynamic sections don’t allow the same field to be in more than one section and are very limited at the current state.

I appreciate if someone could lead me in the right direction on how to find the field placeholders (for both default and custom) and give me an example on how the conditional fields could be set up.

Thank you.

If you inspect the form, you’ll be able to locate the HTML tag element IDs for the type and subject. You can find them in the screenshot below.

You can write the logic in the script tag, as shown in the screenshot below. You can show and hide fields based on the HTML element IDs you retrieve.

1 Like

Hey @bres

we do exactly what you are requesting. We do set the subject when another field was chosen in the contact form:

<script>
  jQuery(document).ready(function(){
         //Add Contact Reason to subject and hide subject
const subject = jQuery("#helpdesk_ticket_subject")[0];
  jQuery("#helpdesk_ticket_custom_field_cf_contact_reason").live('change', function(data){
           if (data.target.value) {
             subject.value = data.target.options[data.target.selectedIndex].text;
             subject.dispatchEvent(new Event("blur"));
           }
         });
         //Hide subject
         jQuery("#helpdesk_ticket_subject").parent().parent().hide();
....

A similar thing can be done with your second request.
On change event could listen to any change of your field and if a specific value is set, just show the other field.

If you use the new portal theme (Marina I guess it is called and Mint is the old one), there is another way to do the same.
You then could leverage end user apps: Freshworks Developer Docs | Build secure end-user apps

Hope this helps.
Tom

1 Like