1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

TicketSubject -- submitticket_form

Discussion in 'Style and design' started by Cindy K., Oct 30, 2013.

  1. Cindy K.

    Cindy K. Member

    Hi Gary,
    You are my hero! Thank you so much for your help!
    Cindy
     
  2. Gary McGrath

    Gary McGrath Staff Member

    You're welcome, glad I was able to help :)

    Gary
     
    Cindy K. likes this.
  3. Circar123

    Circar123 New Member

    Hello,

    Thanks for this code, it's really helpful for me.
     
  4. Barry O Reilly

    Barry O Reilly New Member

    Hi Gary/Anyone,

    Sorry to dig up an old thread. Trying to get the information provided here working. I'm combining two different thread.

    The first problem I had was to hide the Subject and Main body of a ticket which was no problem with an answer you gave in another thread.
    This was done using an IF statement


    <{if $_selectedDepartmentTitle == "RS Communications"}>
    <input type="hidden" name="ticketsubject" value="_">
    <input type="hidden" name="ticketmessage" value="_">
    <{else}>

    That worked fine but now I want to use one of my custom fields as the subject title instead of the defaulted text that I gave ("_")

    I've gone through the steps in this thread to do this but don't think it will work as the ticketsubject is now hard set to "_"
    Is this possible using the code here using the DoSubmit??
    I'm hoping someone can steer me in the right direction.

    The full code I was using is

    <form method="post" onsubmit="DoSubmit()" action="<{$_baseName}><{$_templateGroupPrefix}>/Tickets/Submit/Confirmation" name="SubmitTicketForm" enctype="multipart/form-data" autocomplete="off">
    <div class="boxcontainer">
    <div class="boxcontainerlabel"><{$_language[yourticketdetailstitle]}></div>
    <div class="boxcontainercontent">
    <{$_language[yourticketdetailsdesc]}><br /><br />
    <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[generalinformation]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
    <table width="100%" border="0" cellspacing="1" cellpadding="4">
    <{if $_noContactDetails != '1'}>
    <tr>
    <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_fullname]}></td>
    <td><input name="ticketfullname" type="text" size="25" class="swifttextlarge" value="<{$_ticketFullName}>" /></td>
    </tr>
    <tr>
    <td align="left" valign="middle" class="zebraodd"><{$_language[st_email]}></td>
    <td><input name="ticketemail" type="text" size="25" class="swifttextlarge" value="<{$_ticketEmail}>" /></td>
    </tr>
    <{/if}>
    <{if $_promptTicketType == '1'}>
    <tr>
    <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_type]}></td>
    <td><select name="tickettypeid" class="swiftselect"><{foreach key=key item=_item from=$_ticketTypeContainer}>
    <option value="<{$_item[tickettypeid]}>"<{if $_item[selected] == true}> selected="selected"<{/if}>><{escape $_item[title]}></option>
    <{/foreach}></select></td>
    </tr>
    <{/if}>
    <{if $_promptTicketPriority == '1'}>
    <tr>
    <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_priority]}></td>
    <td><select name="ticketpriorityid" class="swiftselect"><{foreach key=key item=_item from=$_ticketPriorityContainer}>
    <option value="<{$_item[priorityid]}>"<{if $_item[selected] == true}> selected="selected"<{/if}>><{escape $_item[title]}></option>
    <{/foreach}></select></td>
    </tr>
    <{/if}>
    </table>
    <br />
    <{RenderTemplate name="customfields"}>
    <{if $_selectedDepartmentTitle == "RS Communications"}>
    <input type="hidden" name="ticketsubject" value="_">
    <input type="hidden" name="ticketmessage" value="_">
    <{else}>
    <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[st_messagedetails]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
    <table width="100%" border="0" cellspacing="1" cellpadding="4">
    <tr>
    <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_subject]}></td>
    <td width=""><input name="ticketsubject" type="text" size="45" class="swifttextwide" id="ticketsubject" type="hidden" value="RS"/>
    </tr>
    <tr>
    <td colspan="2" align="left" valign="top"><textarea name="ticketmessage" id="ticketmessage" cols="25" rows="15" class="swifttextareawide"><{$_ticketMessage}></textarea><div id="irscontainer" class="irscontainer"><div class="irsui"><div class="irstitle"><{$_language[irsloading]}></div></div></div></td>
    </tr>
    </table>
    <{/if}>
    <br />
    <{if $_settings[t_cenattach] == '1'}>
    <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[uploadfiles]}> [<div class="addplus"><a href="#ticketattachmentcontainer" onclick="javascript: AddTicketFile();"><{$_language[taddfile]}></a></div>]</th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
    <div id="ticketattachmentcontainer">
    </div>
    <{/if}>
    <br />
    <{if $_canCaptcha == true}>
    <table class="hlineheader"><tr><th rowspan="2"><{$_language[verifyticketsubmission]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
    <div class="subcontent"><{$_language[captchadesc]}></div>
    <{$_captchaHTML}>
    <br />
    <{/if}>
    <div class="subcontent"><input class="rebuttonwide2" value="<{$_language[buttonsubmit]}>" type="submit" name="button" /><input type="hidden" name="departmentid" value="<{$_departmentID}>" /><input type="hidden" name="_csrfhash" value="<{$_csrfhash}>" /></div>
    <{if $_canIRS == true}>
    <script type="text/javascript">
    StartIRS();
    </script>
    <{/if}>
    </div>
    </div>


    <script>
    function DoSubmit(){
    document.getElementById("ticketsubject").value = document.getElementById("3ejqgqcui2t1").value;
    return true;
    }
    </script>

    </form>
     
  5. Gary McGrath

    Gary McGrath Staff Member

    On a quick look, that looks ok to me, did you make sure that "3ejqgqcui2t1" in the dosubmit function is the correct "real name"of your custom field?

    Gary
     
  6. Barry O Reilly

    Barry O Reilly New Member

    Hi Gary,

    Thanks for the quick reply. Yes that's the ID that I get when I inspect the element for the custom field I want to use.
    So the dosubmit function should overwrite the default value with the submitted value?

    Not sure what I'm doing wrong then.

    - Barry
     
  7. Gary McGrath

    Gary McGrath Staff Member

    Ok, so the first thing to do when troubleshooting this, if you open up the form in question in a browser and then "view source" can you find your dosubmit code in the source? ( lets make sure its not a caching issue first )

    Gary
     
  8. Barry O Reilly

    Barry O Reilly New Member

    Yup, can see the dosubmit code in view page source.. Code shown below

    <input type="hidden" name="ticketsubject" value="_">
    <input type="hidden" name="ticketmessage" value="_">
    <br />
    <table class="hlineheader"><tr><th rowspan="2" nowrap>Attach Files [<div class="addplus"><a href="#ticketattachmentcontainer" onclick="javascript: AddTicketFile();">Add File</a></div>]</th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
    <div id="ticketattachmentcontainer">
    </div>
    <br />
    <div class="subcontent"><input class="rebuttonwide2" value="Submit" type="submit" name="button" /><input type="hidden" name="departmentid" value="9" /><input type="hidden" name="_csrfhash" value="sfsih5zlidiqk5zt7pbrg5zzwa9ze606" /></div>
    <script type="text/javascript">
    StartIRS();
    </script>
    </div>
    </div>
    <script>
    function DoSubmit(){
    document.getElementById("ticketsubject").value = document.getElementById("3ejqgqcui2t1").value;
    return true;
    }
    </script>

    I can also confirm that I see the 3ejqgqcui2t1 ID on the same page source for the field I am looking to use.

    Thanks Gary
     
  9. Gary McGrath

    Gary McGrath Staff Member

    Ok, I think I might have spotted the issue,

    move the script code:

    <script>
    function DoSubmit(){
    document.getElementById("ticketsubject").value = document.getElementById("3ejqgqcui2t1").value;
    return true;
    }
    </script>

    to after the /form

    Gary
     
  10. Barry O Reilly

    Barry O Reilly New Member

    Tried that but unfortunately if didn't work. Confirmed that the code is outside the </form> by looking at the page source again.
    It just names the subject field with the default that I have set.
    <input type="hidden" name="ticketsubject" value="_">
     
  11. Gary McGrath

    Gary McGrath Staff Member

    ok, change the script function to this:

    Code:
    
    <script>
    function DoSubmit(){
    document.getElementById("ticketsubject").value = "overwrite";
    return true;
    }
    
    
    Lets see if its just not seeing the new value, or not writing it back, that should always make the subject "overwrite"

    Gary
     
  12. Barry O Reilly

    Barry O Reilly New Member

    Didn't update the ticketsubject to "overwrite". I moved the code inside the </form> and tried it there too but no change - still shows as the value "_"

    This means the DoSubmit is not being run? I must have something silly done then.
     
  13. Gary McGrath

    Gary McGrath Staff Member

    Try using this code instead for your function ( outside the /form tag ):

    Code:
    
    <script>
    function DoSubmit(){
    document.SubmitTicketForm.ticketsubject.value = document.SubmitTicketForm.3ejqgqcui2t1.value;
    return true;
    }
    </script>
    
    
    Gary
     
  14. Barry O Reilly

    Barry O Reilly New Member

    Sorry Gary, no luck with that one either.. Put it outside the form tag too.
     
  15. Gary McGrath

    Gary McGrath Staff Member

    hmm, that is a little odd, I literally tested that one myself before posting it and it worked fine for me :confused:

    here is my complete code:

    Code:
    
    <form class="submitticketform" onsubmit="DoSubmit()"  method="post" action="<{$_baseName}><{$_templateGroupPrefix}>/Tickets/Submit/Confirmation" name="SubmitTicketForm" enctype="multipart/form-data" autocomplete="off">
                <div class="boxcontainer">
                <div class="boxcontainerlabel"><{$_language[yourticketdetailstitle]}></div>
    
                <div class="boxcontainercontent">
                <{$_language[yourticketdetailsdesc]}><br /><br />
                <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[generalinformation]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
                <div class="form-table">
                <table width="100%" border="0" cellspacing="1" cellpadding="4">
                    <{if $_noContactDetails != '1'}>
                    <tr>
                        <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_fullname]}></td>
                        <td><input name="ticketfullname" type="text" size="25" class="swifttextlarge" value="<{$_ticketFullName}>" /></td>
                    </tr>
                    <tr>
                        <td align="left" valign="middle" class="zebraodd"><{$_language[st_email]}></td>
                        <td><input name="ticketemail" type="text" size="25" class="swifttextlarge" value="<{$_ticketEmail}>" /></td>
                    </tr>
                    <{/if}>
                    <{if $_promptTicketType == '1'}>
                    <tr>
                        <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_type]}></td>
                        <td><select name="tickettypeid" class="swiftselect"><{foreach key=key item=_item from=$_ticketTypeContainer}>
                        <option value="<{$_item[tickettypeid]}>"<{if $_item[selected] == true}> selected="selected"<{/if}>><{escape $_item[title]}></option>
                        <{/foreach}></select></td>
                    </tr>
                    <{/if}>
                    <{if $_promptTicketPriority == '1'}>
                    <tr>
                        <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_priority]}></td>
                        <td><select name="ticketpriorityid" class="swiftselect"><{foreach key=key item=_item from=$_ticketPriorityContainer}>
                        <option value="<{$_item[priorityid]}>"<{if $_item[selected] == true}> selected="selected"<{/if}>><{escape $_item[title]}></option>
                        <{/foreach}></select></td>
                    </tr>
                    <{/if}>
                </table>
                </div>
                <br />
                <{RenderTemplate name="customfields"}>
    
                <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[st_messagedetails]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
                <div class="form-table">
                <table width="100%" border="0" cellspacing="1" cellpadding="4">
                    <tr>
                        <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_subject]}></td>
                        <td width=""><input name="ticketsubject" type="text" size="45" class="swifttextwide" id="ticketsubject" value="<{$_ticketSubject}>" /></td>
                    </tr>
                </table>
                <table width="100%" border="0" cellspacing="1" cellpadding="4">
                    <tr>
                        <td colspan="2" align="left" valign="top"><textarea name="ticketmessage" id="ticketmessage" cols="25" rows="15" class="swifttextareawide"><{$_ticketMessage}></textarea><div id="irscontainer" class="irscontainer"><div class="irsui"><div class="irstitle"><{$_language[irsloading]}></div></div></div></td>
                    </tr>
                </table>
                </div>
                <br />
    
                <{if $_settings[t_csccrecipients] == '1'}>
                <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[st_recipients]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
                <div class="subcontent"><{$_language[st_recipientsdesc]}></div>
                <table width="100%" border="0" cellspacing="1" cellpadding="4">
                <tr>
                    <td width="200" align="left" valign="middle" class="zebraodd"><{$_language[st_cc]}></td>
                    <td width=""><input name="ticketcc" type="text" size="25" class="swifttextwide" id="ticketcc" value="<{$_ticketCC}>" /></td>
                </tr>
                </table>
                <br />
                <{/if}>
    
                <{if $_settings[t_cenattach] == '1'}>
                <table class="hlineheader"><tr><th rowspan="2" nowrap><{$_language[uploadfiles]}> [<div class="addplus"><a href="#ticketattachmentcontainer" onclick="javascript: AddTicketFile();"><{$_language[taddfile]}></a></div>]</th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
                <div id="ticketattachmentcontainer">
                </div>
                <{/if}>
                <br />
    
                <{if $_canCaptcha == true}>
                <table class="hlineheader"><tr><th rowspan="2"><{$_language[verifyticketsubmission]}></th><td>&nbsp;</td></tr><tr><td class="hlinelower">&nbsp;</td></tr></table>
                <div class="subcontent"><{$_language[captchadesc]}></div>
                <{$_captchaHTML}>
                <br />
                <{/if}>
    
                <div class="subcontent"><input class="rebuttonwide2" value="<{$_language[buttonsubmit]}>" type="submit" name="button" /><input type="hidden" name="departmentid" value="<{$_departmentID}>" /><input type="hidden" name="_csrfhash" value="<{$_csrfhash}>" /></div>
    
    
                <{if $_canIRS == true}>
                <script type="text/javascript">
                StartIRS();
                </script>
                <{/if}>
                </div>
                </div>
            </form>
    
    <script>
    function DoSubmit(){
    document.SubmitTicketForm.ticketsubject.value = document.SubmitTicketForm.c6zoph6urubt.value;
    return true;
    }
    </script>
    
    
    Gary
     
  16. Barry O Reilly

    Barry O Reilly New Member

    Hi Gary,

    Sorry only replying now. In New Zealand so time difference isn't helping. I copied all you code and changed the

    document.SubmitTicketForm.ticketsubject.value = document.SubmitTicketForm.c6zoph6urubt.value;

    to show my unique ID and that did not overwrite the subject field. This code doesn't hide the Subject field and main Your Message text fields but that doesn't matter at the moment as
    it's not updating. I can work on that later.

    So the only other thing that needs to change is adding the line in the custom fields template??
    <input name="<{$_customField[fieldname]}>" id="<{$_customField[fieldname]}>" type="text" autocomplete="off" size="20" class="swifttextlarge" value="<{$_customField[fieldvalue]}>">

    What versions of Kayako does this work for? I know this thread was for 4.63 and i'm using 4.69.
     
  17. Gary McGrath

    Gary McGrath Staff Member

    I tested my code on Kayako 4.72, but it should honestly work on any version of Kayako ( as its basic javascript in the browser, its not Kayako specific )

    Gary
     
  18. bigtooth

    bigtooth Member

    Does anyone know how to do this same thing except for a field that is a drop down list instead of text? I got it to work but since each drop down has its own ID, it simply shows the OPTION VALUE for that custom field and not the actual text assigned to the value. Is this possible to do with a drop down select?
     

Share This Page