Tip: How to auto populate content of description field

5 Commentaires

  • B

    Hi, Trapta!

    We tried this with this code:

    $(document).ready(function() {
    var fieldID = '7603499055631'; // replace with your custom field ID
      // Set the value of the selected dropdown option to a variable
      $('#request_custom_fields_7603499055631').change(function() {
          var category = $(this).val(); // Get the selected option's value when it changes
          // Compare the selected option's value
          if (category == 'tools__mdm') {
        $('#request_subject').val("Issue Encountered: XXXX").change();
    tinymce.get("request_description").setContent("<p>Test</p>");
          }
        })
      });

    But unfortunately, this does not work.

    The subject is filled out but the description is not, any ideas?

    0
  • Trapta Singh
    Community Moderator
    Zendesk Luminary

    Hi B,

    Are you getting any error? Also, make sure that the condition for comparing selected options is working.

    Thanks

    Trapta

    0
  • B

    Hey Trapta Singh

    Thanks for getting back to me.

    I indeed got a console error tinymce is undefined

    I believe the problem is with the request description line, the normal code:

        $('#request_description').val("Test").change();

    does not work because the change function do not work on rich text editors (which Zendesk currently has)

    I can confirm that the conditions are working fine since the subject field is auto-populated.

    0
  • Trapta Singh
    Community Moderator
    Zendesk Luminary

    B,

    You don't have to use .change() to set the request_description value. You can simply use 

    $('#request_description').val("Test")

    to set the description value.

    You can refer to the post to get the context.

    Let me know if this helps you.

    Thanks

    0
  • B

    Hi, Trapta Singh!

    We also tried that one but still does not work.

    We're not receiving any errors but there is nothing that's filled out in our description field.

    0

Vous devez vous connecter pour laisser un commentaire.

Réalisé par Zendesk