0

I want to include javascript in my web-to-case from. My sole purpose of doing so is to Query from Salesforce Database in that form. How can I achieve this functionality. Can I use some controller as extension to my Web-to-Case form?

--> alert('dgdgg'); var chatt = sforce.connection.query("SELECT Id FROM LiveChatButton where DeveloperName = 'Chat_Button'") ;

        var deploy = sforce.connection.query("SELECT Id FROM LiveChatDeployment where DeveloperName = 'Customer_Support_Chat'") ;  
    </script>
    <form name="myformMSG" id="myformMSG" hidden="true">
        <label id="prova"></label>
    </form>

    <form id="myform" name="myform" action="https://www.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8"  method="POST">
    <input type="hidden" name="orgid" value="{!$Organization.Id}"/>
    <input type="hidden" name="retURL" value="{!$Site.Domain}{!URLFOR($Page.Thanks)}"/>
  • Yes you can add a extension and can query the record – Tushar Sharma Oct 16 '15 at 7:02
  • Hey could you please help me with a code snippet. I have mentioned my code below, please could you check it? – happy Oct 16 '15 at 7:08
  • what code you need here? – Tushar Sharma Oct 16 '15 at 7:12
  • Just the snippet of how to add controller to web-to-case from? – happy Oct 16 '15 at 7:17
  • are you using this page in Apex:pages – Tushar Sharma Oct 16 '15 at 7:57
0
<apex:page standardcontroller="case" extensions="CaseExt">
    <script>
        var chatt = sforce.connection.query("SELECT Id FROM LiveChatButton where DeveloperName = 'Chat_Button'") ;
        var deploy = sforce.connection.query("SELECT Id FROM LiveChatDeployment where DeveloperName = 'Customer_Support_Chat'") ;  
    </script>
    <form name="myformMSG" id="myformMSG" hidden="true">
        <label id="prova"></label>
    </form>

    <form id="myform" name="myform" action="https://www.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8"  method="POST">
    <input type="hidden" name="orgid" value="{!$Organization.Id}"/>
    <input type="hidden" name="retURL" value="{!$Site.Domain}{!URLFOR($Page.Thanks)}"/>

    User Name : <input type="text" value="{!user.Username}" />
</apex:page>

Controller

public class CaseExt {
    public user user;
    public CaseExt (ApexPages.StandardController stdController) {
        user = [SELECt Id, Username from user where Id =: userIfo.getuserId()];
    }
}

This is a just simple piece of code to give you understanding how you can use extension in your form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.