How to pre-fill description box based on Custom Field value

Answered

7 Comments

  • Trapta Singh
    Community Moderator

    HiLou,

    Try the below code:

    tinymce.get("request_description").setContent("

    Description 1

    ");

    Let me know how it goes for you.

    Thanks

    0
  • Lou
    Community Moderator
    The Product Manager Whisperer - 2022

    When you say description, are you referring to the subject field? If so, we use a trigger and extension to make that change. It's completely automated based on if the field has a value.

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    HiPatrick Lieu, I got something for you:

    HTML: Add at any page

    Description One

    Description Two

    Description Three

    < div id = " option4 " class = "集团" >描述四< /div>

    Script code:

    $(document).ready(function () {
    $('.group').hide();
    $('#option1').show();
    $('#selectMe').change(function () {
    $('.group').hide();
    $('#'+$(this).val()).show();
    })
    });

    Output is:

    I'm not sure but may be you can do something with this code via changing the classes in script code.

    You can add script code only and add the classes of your custom dropdown.

    Thanks

    0
  • shelley

    Ifra Saqlainthe Output image is missing, can you please add. Trying to work out if this will work for our needs. Thank you :)

    0
  • Marsy

    Hello, I am trying to add a description template based on a custom field id's and their associated tags. I listed custom field 1 and 3. Custom field 3 is a child field of Custom Field 1. My code worked fine up until last week. For some reason it stopped working and also disabled the users dropdown menu to view their activities and requests.

    Here is the code I have added into the JS

    /*
    $(document).ready(function () {
    var ticketForm = location.search.split("ticket_form_id=")[1];
    if(ticketForm == 400000000000) {
    $("#request_description").val();
    }
    });

    function descriptionFormat(){
    let serviceType = {
    ID助教g1 : "1. Do you have the current version of the App? (Update version),
    ID助教g 2 :""
    }

    let IssueType = {
    ID助教g3 : "Does the member have the current App version?
    }

    const serviceTypeNode= document.getElementById(document.querySelector("#new_request > div.form-field.string.required.request_custom_fields_ID_1 > a").getAttribute("aria-controls"));

    const config = { attributes: true, childList: true, subtree: true };

    const serviceTypeCallback = function (mutationsList, observer) {
    for (const mutation of mutationsList) {
    if (mutation.attributeName == "aria-selected")
    {
    if (Object.keys(serviceType).indexOf(mutation.target.id)>=0) {
    document.getElementById('request_description_ifr').contentWindow.document.querySelector("p").innerText = serviceType[mutation.target.id];
    if (mutation.target.id == "ID_3"){
    const IssueTypeNode= document.getElementById(document.querySelector("#new_request > div.form-field.string.request_custom_fields_ID#.required > a").getAttribute("aria-controls"));
    issueTypeObserver.observe(IssueTypeNode, config);
    }
    }
    else {
    document.getElementById('request_description_ifr').contentWindow.document.querySelector("p").innerText = "";
    }
    }
    }
    };

    const IssueTypeCallback = function (mutationsList, observer) {
    for (const mutation of mutationsList) {
    if (mutation.attributeName == "aria-selected")
    {
    if(Object.keys(IssueType).indexOf(mutation.target.id)>=0){
    document.getElementById('request_description_ifr').contentWindow.document.querySelector("p").innerText = IssueType[mutation.target.id];
    }
    else{
    document.getElementById('request_description_ifr').contentWindow.document.querySelector("p").innerText = serviceType["Issue Type Tag"];
    }
    }
    }
    };

    const serviceTypeObserver = new MutationObserver(serviceTypeCallback);
    const issueTypeObserver = new MutationObserver(IssueTypeCallback);

    serviceTypeObserver.observe(serviceTypeNode, config);
    }

    if (document.querySelector('#new_request a[aria-label="Please choose your issue below"]').innerText == "Form Name 1"){
    descriptionFormat();
    }

    0
  • Zach

    I have a similar ask... Does anyone have experience populating a custom name for the description box, based on a field value?

    for example,
    if tech support issue = "document upload" then description title reads: "Please provide any details about your document upload"
    &
    if tech support issue = "platform issues" then description title reads: "Please provide information about the platform you're using"

    0
  • Julio H
    Zendesk Customer Care
    Hi Zach,

    Thanks for your feedback.

    This is not currently possible. As a workaround, you can use conditional fields.

    Creating conditional ticket fields

    When an end user selects a value from the field support issue. Then the system can show a different type of fields to request different information from each value in that field.

    For example:

    If user selects support issue = "document upload" then show the following fields: Do you attach your documents? (yes / no)

    I hope it helps.
    0

Pleasesign into leave a comment.

Powered by Zendesk