Can I hide "Editable for end-users" fields in the Request form?

Answered

9 Comments

  • Simon Blouner
    Community Moderator

    Hey Duc Bui

    You can hide these field with JS.

    You would add the JS in you script.js file, right inside your $(.document.ready) function.

    $('.request_custom_fields_INSERT-TICKET-FIELD-ID-HERE').hide();

    #helpsome regards,
    Simon Blouner
    Zendesk Consultant @ helphouse.io

    1
  • Duc Bui

    Thank you very much, Simon.

    0
  • Judy Huynh

    Hey Simon Blouner - I am embeding my widget JS code on my personal website locally, however the jquery to hide the ticket field does not work.

    This is how my jquery script tag is implemented in my html document head -

    <!DOCTYPE html>

    <html>

    <head>

    <metacharset="UTF-8"/>
    <metaname="viewport"content="width=device-width, initial-scale=1"/>

    <script
    src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
    integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
    crossorigin="anonymous"
    ></script>

    <link
    rel="stylesheet"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
    integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
    crossorigin="anonymous"
    />
    <script src="./widget.js"></script>
    <title>Judy Co.</title>

    </head>

    Below is my Widget code where I'm embeding it directly in the HTML:

     

    <script

    id="ze-snippet"

    src="https://static.zdassets.com/ekr/snippet.js?key=240c5f72-09e9-4ea4-b054-24035ced0325"

    ></script>

    <scripttype="text/javascript">

    zESettings = {
    webWidget: {
    launcher: {
    label: {
    "en-US":"Need help?"
    }
    },

    contactForm: {
    ticketForms: [{ id:360000929731 }],
    fields: [
    {
    id:"360032045411",
    prefill: { "*":"test text" }
    }
    ]
    }
    }
    };
    </script>

    Below is my `widget.js` code to hide the field that's NOT WORKING:

    $(document).ready(function() {

    $(".request_custom_fields_360032045411").hide();
    $('.form-field.request_description').hide(); // Hide descriptionconsole.log("ready!!!!!!");

    });
    0
  • Simon Blouner
    Community Moderator

    Hey Judy Huynh

    My initial thought based on the provided snippets, is that you're not including the widget.js file.

    You're writing the following:

    <scriptsrc="./widget.js"></script>

    Could it be that you need to add a "space" in your reference, in the beginning - so it would say the following:

    <script src="./widget.js"></script>

     

     

    0
  • Judy Huynh

    Apologies @simon blounder, please ignore any spacing issues you noticed. When I pasted my code as a comment in this thread, it created so much white space - I manually tried to eliminate the white space in this thread to make it a cleaner read. However, in my actual code - it is showing correctly as 

    <script src="./widget.js"></script>

    Apologies for the confusion. I can confirm my javascript is linked correctly.. I don't know why the jquery isn't working. Is it only expected to work in Zendesk's guide code in the design section ? 

    0
  • Simon Blouner
    Community Moderator

    Hey Judy Huynh

    The original poster of this post is hiding fields on his Help Center, on the new request page.

    Are you trying to hide fields in the Web widget itself?

    If you need to hide a field in the web widget, you should consider just not having it visible to the end-user, which can be set in the settings of the actual field in Zendesk Support.

    If you, however, do want to hide fields in the web widget, you can have a look at this Github project - I believe to have seen others have success with it before.

    I am however in doubt you're going to be able to submit a request through the web widget, without having content in the description/comment field, which it looks like you're trying to hide :-)

    0
  • Justin Federico

    Hello,

    If we have a drop-down field on the request page but there is a particular field value that we would like to hide from the end-user, would this be possible?

    0
  • Karen Snyder
    Community Moderator

    Justin Federico

    In this comment, I showed code that I used to hide an option if the user was not in certain groups. It may be helpful to you.

    1
  • Justin Federico

    Karen Snyder

    Thank you, Karen. This is very helpful!

    0

Please sign in to leave a comment.

Powered by Zendesk