APIv4: How to hide the organization field on contact form



image avatar

Bryan

Zendesk Luminary

Posted Oct 31, 2024

Hi all! I just updated my help center theme from APIv2 to v4 in order to get greater form customization options. But I'm currently finding it more difficult. Hoping to find some advice.

In particular, I need the organization field on the contact form to be hidden. The customer's default organization is fine to pass through. But they don't need to see other organizations if they're part of more than one.

Ideally, it would be great if the field ID was added as a class for the div that contains each form field. But I'm struggling to make sense of the new js assets that are in the latest Copenhagen theme. Can anyone point me in the right direction for this?


0

4

4 comments

Hi Dustin,
 
Thanks for sharing your approach. The idea of using document.addEventListener("DOMContentLoaded", function() { ... }); to check the field value on page load makes sense, but there might be timing or scope issues affecting the alert trigger.
 
You might want to try adding an event listener directly to the specific input or select element to catch value changes in real time, for example using element.addEventListener('change', function() { ... }).
 
Also, ensuring the field selector is correct and that the script runs after the elements are fully rendered can help.

0


How can I pop an alert in a certain field equals a value on change?  tried this:

 

document.addEventListener("DOMContentLoaded", function() {
   // Check if the value in props.requestForm.ticket_fields[256] is "No"
   if (props.requestForm.ticket_fields[256] && props.requestForm.ticket_fields[256].value === "no_rejects") {
       // Trigger the alert
       alert("The value is 'No'. Please take necessary action.");
   }
});

 

but doesn't work….

0


Amazing! Thank you sir.

0


You can achieve it with React with this prompt in the new_request_page.hbs

props.requestForm.organization_field = false;

 

1


Sign in to leave a comment.

Didn't find what you're looking for?

New post