Recent searches


No recent searches

Tip: How to auto populate content of description field



image avatar

Trapta Singh

Zendesk LuminaryCommunity Moderator

Posted Jul 30, 2021

This tip will help you add value to the description field by submitting a request form in the guide theme.

You can use the code when you want to prefill the description or can simply put the code under the condition where you can auto-populate the description field when certain conditions are met.

Use the below line of code to set the value for the description field.

tinymce.get("request_description").setContent("<p>Test</p>”);

You can also take a look at this post where the code was originally shared. Let us know if you face any issues.

Thanks


3

5

5 comments

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


image avatar

Trapta Singh

Zendesk LuminaryCommunity Moderator

Hi B,

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

Thanks

Trapta

0


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


image avatar

Trapta Singh

Zendesk LuminaryCommunity Moderator

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


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


Please sign in to leave a comment.

Didn't find what you're looking for?

New post