• devForce007
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hello Every One,

I need some help .

I create a custom page which is similar to Standard email page.

Now my requirement is that whenever the recipient open the mail.I will notify by an email or any thing that recepient open mail or recipient get mail.

 

How i can do it?please help!!!!

 

For refrenceces  i pasted my Visual force page & Apex Class here.

public class ReplyLead{
     private final Task ts{get;set;}
     public EmailMessage email{get;set;}
     public Task tsk{get;set;}
     public string additionalTo{get;set;}
     public string to{get;set;}
     public string cc{get;set;}
     public String bcc{get;set;}
     public String attachment{get;set;}
     public List<Attachment> attList{get;set;}
     public String subject{get;set;}
     public String body{get;set;}
     public String currentAttId;
     public String currentQuoteId;
     public Boolean toAddpresent;
     public Boolean sendSuccess{get;set;}
     public Quote qt{ get; set; }
     public User usr{ get; set; }
     public Quote UserEmail;
     public String[] jsonDescriptionData;
     public String parentId {get;set;}
    // public Attachment attach {get;set;}
       public String filename{get;set;}
        public Attachment attach{get;set;}
        public String recNo{get;set;}
        public String attachId{get;set;}
        public String FName{get;set;}
             Public String fSize{get;set;}
             Public blob bodypart{get;set;}
          Public Boolean inLine{get;set;}
         public transient  String fbody{get;set;}
       //public List<AttachmentWrap > attList1{get;set;}
     public ReplyLead(ApexPages.StandardController controller){
        email=new EmailMessage();
        qt= new Quote();
        toAddpresent=false;
        sendSuccess=false;
        attach = new Attachment();
        currentQuoteId=ApexPages.currentPage().getParameters().get('retURl');
        UserEmail=[select Id,contact.Email from Quote where Id=:currentQuoteId limit 1];
        if(UserEmail.contact.Email !=null || UserEmail.contact.Email!= '')
            to = UserEmail.contact.Email;
            
        currentAttId=ApexPages.currentPage().getParameters().get('attid');
        attList=new List<Attachment>();
        attList=[Select id,Name,Body From Attachment WHERE Id=:currentAttId LIMIT 1];
        System.debug('*********************************'+currentAttId);
        this.ts=(Task)controller.getRecord();
        tsk= new Task();
    }
   /* public void replyRec(){
    System.debug('**************replyRec**************');
         qt= new Quote();
    
     }*/
    
   public void upload()
    {
       
        //This shows how to insert an Attachment
        attach.ParentId = currentQuoteId;
        
        insert attach;
       
        //return new ApexPages.Standardcontroller(attach).view();  
    }
     public void doAttachment(){
        try{    
         Attachment at=new Attachment();
         system.debug('filename:'+filename);
         system.debug('fbody:'+fbody);
         system.debug('fSize:'+fSize);
         at.Name=filename;
         at.parentId =currentQuoteId;
         String substring = fbody.substring(0, (fbody.indexOf(',')+1));
          system.debug(substring );
         at.Body =EncodingUtil.base64Decode(fbody.replace(substring ,''));//Blob.valueOf(fbody);
         

        // at.inLine=false;
        // insert at;
        
         attList.add(at);
       }
       catch(exception r){
         ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Attachment Size Crossed limit');
         ApexPages.addMessage(myMsg);
       }
                                   
    }
    public List<string> getjsonDescriptionData(){
        try{
            jsonDescriptionData = new List<string>();
            List<User> UserList = [select id,Email,Name from User];
            List<Contact> conList=[Select id,Email From Contact];
            if(UserList != null && UserList .size() != 0){
                Set<String > EmailSet= new Set<String>();
                for(User acc : UserList){
                    EmailSet.add(acc.Email);
                }
                for(Contact con : conList){
                    EmailSet.add(con.Email);
                }
                for(String nam : EmailSet){
                    jsonDescriptionData.add('"'+nam+'"');
                }
            }
        }catch(Exception ex){
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,ex.getMessage()));
             return null;
        }
      jsonDescriptionData.sort();
      return jsonDescriptionData;
      }
      
      
    public PageReference sendReply() {
     System.debug('**************sendReply**************');
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        //attach.setFileName(attList[0].name + 'pdf');
       // attach.setBody(attList[0].Body);
        system.debug('attList:'+attList);
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a :attList){
             Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
             efa.setFileName(a.Name);
               
                
             // a.body = EncodingUtil.base64Decode((a.body.tostring()).replace('data&colon;text/plain;base64',''));
              system.debug(fbody);
             efa.setBody( a.body);
             
            fileAttachments.add(efa);
        
        
        }
        
        if(to != null && to != ''){
            email.setToAddresses(to.split(',').size()  > 0 ? to.split(',') : new String[]{to});
            toAddpresent=true;
        }
        if(cc != null && cc != ''){
            email.setCcAddresses(cc.split(',').size()  > 0 ? cc.split(',') : new String[]{cc});
        }
        if(bcc != null && bcc != ''){
            email.setBccAddresses(bcc.split(',').size()  > 0 ? bcc.split(',') : new String[]{bcc});
        }
        email.setSubject( subject );
        email.setHtmlBody( body );
        email.setFileAttachments(fileAttachments);
       // email.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
         if(toAddpresent){
            
            if(!Test.isRunningTest()){
            Messaging.SendEmailResult [] r =Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
            }
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Email Send Successfully'));
           sendSuccess=true;
            return null;
        }else{
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'To Address is mandatory to send email,Please Enter To address'));
            return null;
        }
        
    }
    public PageReference redirectQuotePage(){
     System.debug('**************redirectQuotePage**************');
        PageReference pageRef=new PageReference('/'+currentQuoteId);
            pageRef.setRedirect(true);
            return pageRef;
    }
   
}

/////////////////////////////////////

<apex:page standardcontroller="Task" extensions="ReplyLead" id="pg">
 <apex:includeScript value="{!URLFOR($Resource.jquery1, 'js/jquery-1.6.2.min.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery1, 'js/jquery-ui-1.8.16.custom.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.jquery1, 'css/ui-lightness/jquery-ui-1.8.16.custom.css')}"/>
   <!-- <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
    <link rel="stylesheet" href="/resources/demos/style.css" />-->
      <apex:form >
      
          <apex:actionFunction name="goController" action="{!doAttachment}" rerender="pgblkta" >
            <apex:param name="fsize" value="" assignTo="{!fSize}"/>
            <apex:param name="fname" value="" assignTo="{!filename}"/>
            <apex:param name="fbody" value="" assignTo="{!fbody}"/>
        </apex:actionfunction>
      </apex:form>
    <apex:form id="fm" >
    <apex:pageMessages />

        <script type="text/javascript">
        var blobfile;
        function getAsText(readFile){
            var reader = new FileReader();
            reader.readAsDataURL(readFile);
            
                reader.onload = loaded;
            }
            function loaded(evt) {  
                var fileString = evt.target.result;
                blobfile = fileString;
                var  input = document.getElementById("fileId");
                var fileName= input.value;
                var size = input.files[0].size;
               console.log(blobfile);
                goController(size,fileName,blobfile);
                 
            }
            function remoteLocationPost(){
                var fbody= document.getElementById("fileId").files[0];
              //  alert(fbody);
                getAsText(fbody);
            }
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
           
        </script>
        
        <apex:actionFunction name="redirectPage" action="{!redirectQuotePage}" />
        <apex:pageMessages id="errorMsg"/>
        <apex:sectionHeader title="Activity" subtitle="Send a Reply" help="www.google.com" />
        <apex:pageBlock id="pbmain" >
            <center>
                <apex:commandButton id="send" value="Send" action="{!sendReply}"  oncomplete="callMethod();" reRender="errorMsg"/>
                <apex:commandButton id="Cancel" value="Cancel"  oncomplete="callMethod();" />
            </center>                     
            <apex:pageBlockSection id="pbscontid" columns="1">
                <apex:pageBlockSectionItem >
                
                    <apex:outputText title="To" value="To:" />                            
                    <apex:inputTextArea value="{!to}" style="width: 200px; height: 35px;" required="true" styleClass="selectValue" />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                
                <apex:outputText title="CC(New PopupWindow)" value="CC:" />                            
                   <apex:inputTextArea value="{!cc}" id="tags"  style="width: 200px; height: 35px;" required="false" styleClass="selectValue" />
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                
                <apex:outputText title="BCC(New PopupWindow)" value="BCC:"/>                            
                  <apex:inputTextArea value="{!bcc}" id="p26"  style="width: 200px; height: 35px;" required="false" styleClass="selectValue"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Subject" id="sbid" for="subid"/>                            
                    <apex:inputText value="{!subject}" label="Email" id="subid" style="width: 430px; height: 20px;" />                             
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel for="bodyid" value="Body"/>
                    <apex:inputTextarea value="{!body}" id="bodyid"  richText="true"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock title="Attachment" id="AttachId">
        <apex:pageBlockSection >

           
             <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Click the Browse button to find the file.(The file cannot be larger than 135KB and total attachment should not exceed  10MB.)"/>
                    <input type="file" id="fileId" name="attFile" /><br/>
                    <input type="button" value="Save" onclick="remoteLocationPost();" />
                </apex:pageBlockSectionItem>
               
         </apex:pageBlockSection>    

            <apex:pageBlockTable value="{!attList}" var="at" id="pgblkta">
                <apex:column value="{!at.Name}" headerValue="Name"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    <script>
        function callMethod(){
        
            var isCheck="{!sendSuccess}";
            if (isCheck ==1)
            alert("Email was sent successfully!!");
            redirectPage();
       
        }
    </script>
     <script>
    $(function() {
       function split( val ) {
            return val.split( /,\s*/ );
        }
        function extractLast( term ) {
            return split( term ).pop();
        }
        $(".selectValue")
       .bind( "keydown", function( event ) {
                if ( event.keyCode === $.ui.keyCode.TAB &&
                        $( this ).data( "ui-autocomplete" ).menu.active ) {
                    event.preventDefault();
                }
            })
        .autocomplete({
            minLength: 0,
            source: function( request, response ) {
                // delegate back to autocomplete, but extract the last term
                response( $.ui.autocomplete.filter(
                    {!jsonDescriptionData}, extractLast( request.term ) ) );
            },
            focus: function() {
                // prevent value inserted on focus
                return false;
            },
            select: function( event, ui ) {
                var terms = split( this.value );
                // remove the current input
                terms.pop();
                // add the selected item
                terms.push( ui.item.value );
                // add placeholder to get the comma-and-space at the end
                //terms.push( "" );
                //this.value = terms.join( "" );
                this.value = terms;
                return false;
            }
        });
       
    });
    </script>

</apex:page>

Hello Guys,

I have a requirement in which one tab having all account name by click on the accont name.next tab will automatically display all the Related contact name.My problem is in next tab is not rendering so contact name is not display.

My Vf page is 



<apex:page controller="JqueryTab">
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://benalman.com/code/projects/jquery-hashchange/jquery.ba-hashchange.js"></script>        
 
  <script type="text/javascript">
            var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
            document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
        </script>
        <script type="text/javascript">
            try {
                var pageTracker = _gat._getTracker("UA-16380505-1");
                pageTracker._trackPageview();
            }
            catch (err) {
            } 
        </script>
        <script>
        $(function () {
   var items = $('#v-nav>ul>li').each(function () {
       $(this).click(function () {
           //remove previous class and add it to clicked tab
           items.removeClass('current');
           $(this).addClass('current');
 
           //hide all content divs and show current one
           $('#v-nav>div.tab-content').hide().eq(items.index($(this))).show('fast');
 
           window.location.hash = $(this).attr('tab');
       });
   });
 
   if (location.hash) {
        showTab(location.hash);
   }
   else {
       showTab("tab1");
   }
 
   function showTab(tab) {
       $("#v-nav ul li:[tab*=" + tab + "]").click();
   }
 
   // Bind the event hashchange, using jquery-hashchange-plugin
   $(window).hashchange(function () {
       showTab(location.hash.replace("#", ""));
   })
 
   // Trigger the event hashchange on page load, using jquery-hashchange-plugin
   $(window).hashchange(); });
        </script>
        
        <script>
        function getAccId(AccId)
        {
        alert(AccId);
        getRelateCon(AccId);
        }
        function getconId(ConId)
        {
        alert(ConId);
        }
        </script>
 <style>
body
{
   background-color: #f7f7f7;
   margin: 0;
   padding: 0;
}
 
.wrapper
{
   width: 960px;
   margin: 0px auto;
   padding-top: 20px;
   min-height: 600px;
}
 
.wrapper h1, .wrapper h4, .wrapper p, .wrapper pre, .wrapper ul, .wrapper li
{
   margin: 0;
   padding: 0;
   border: 0;
   vertical-align: baseline;
   background: transparent;
}
 
.wrapper li
{
   outline: 0;
   text-decoration: none;
   -webkit-transition-property: background color;
   -moz-transition-property: background color;
   -o-transition-property: background color;
   -ms-transition-property: background color;
   transition-property: background color;
   -webkit-transition-duration: 0.12s;
   -moz-transition-duration: 0.12s;
   -o-transition-duration: 0.12s;
   -ms-transition-duration: 0.12s;
   transition-duration: 0.12s;
   -webkit-transition-timing-function: ease-out;
   -moz-transition-timing-function: ease-out;
   -o-transition-timing-function: ease-out;
   -ms-transition-timing-function: ease-out;
   transition-timing-function: ease-out;
}
 
#v-nav
{
   height: 100%;
   margin: auto;
   color: #333;
   font: 12px/18px "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
}
 
#v-nav >ul
{
   float: left;
   width: 210px;
   display: block;
   position: relative;
   top: 0;
   border: 1px solid #DDD;
   border-right-width: 0;
   margin: auto 0 !important;
   padding:0;
   border: 1px solid #ECECEC;
}
#v-nav > div.tab-content {
   background-color: #FFFFFF;
   border: 1px solid #ECECEC;
   box-shadow: 0 0 35px 5px #FAFBFD inset;
   display: none;
   margin-left: 210px;
   min-height: 400px;
   padding: 25px;
   position: relative;
   z-index: 9;
}
#v-nav >ul >li
{
   width: 180px;
   list-style-type: none;
   display: block;
   text-shadow: 0px 1px 1px #F2F1F0;
   font-size: 1.11em;
   position: relative;
   border-right-width: 0;
   border-bottom: 1px solid #DDD;
   margin: auto;
   padding: 10px 15px !important;  
   background: whiteSmoke; /* Old browsers */
   background: -moz-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* FF3.6+ */
   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #f2f2f2)); /* Chrome,Safari4+ */
   background: -webkit-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* Chrome10+,Safari5.1+ */
   background: -o-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* Opera 11.10+ */
   background: -ms-linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* IE10+ */
   background: linear-gradient(top, #ffffff 0%, #f2f2f2 100%); /* W3C */       
}
 
#v-nav >ul >li.current
{
   color: black;
   border-right: none;
   z-index: 10; 
   background: white !important;
   position: relative;
   moz-box-shadow: inset 0 0 35px 5px #fafbfd;
   -webkit-box-shadow: inset 0 0 35px 5px #fafbfd;
   box-shadow: inset 0 0 35px 5px #fafbfd;
}
 
#v-nav >ul >li.first.current
 </style>
 
    
<!-- -->
 <apex:form style="background-color: #f7f7f7" id="formId">
 
  <apex:actionFunction action="{!getRelatedContact}" name="getRelateCon" rerender="">
        <apex:param name="AccId" assignTo="{!strAccId}" value="AccId" />
 </apex:actionFunction>   
<div class="wrapper" id="mainDiv">
            <h1 class="title">Relations</h1>
            <div id="v-nav">
                <ul>
                    <li tab="tab1" class="first current">Accounts</li>
                    <li tab="tab2">Related Contact</li>
                    <li tab="tab3">Related Opportunity</li>
                    <li tab="tab4" class="last">Realted Custom Object</li>
                </ul>
 
                <div class="tab-content" id="divCon">
                <table>
               <apex:repeat value="{!lstAccount}" var="row">
               <tr>
              
               <td>
                   <h4>
                      <u>
                     <apex:outputPanel id="thePanel" onclick="getAccId('{!row.Id}')">
                      <u><apex:outputText value="{!row.Name}" style="cursor:pointer;"/></u>
                      </apex:outputPanel>
                      </u>
                   </h4>
               </td>
               </tr>
               </apex:repeat>
             </table>   
                </div>
 
                <div class="tab-content" id="div2Id">
                   
                    
                    
                    <table id="tableId">
               <apex:repeat value="{!lstContact}" var="con">
               <tr>
              
               <td>
                   <h4>
                      <u>
                     <apex:outputPanel id="thePanel1" onclick="getconId('{!con.Id}')">
                      <u><apex:outputText value="{!con.Name}" style="cursor:pointer;"/></u>
                      </apex:outputPanel>
                      </u>
                   </h4>
               </td>
             </tr>
             </apex:repeat>
             </table>   
                </div>
                
 
                <div class="tab-content">
                  
                </div>
 
                <div class="tab-content">
                </div>
 
            </div>
        </div>
 
 </apex:form>
</apex:page>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
and My controller is :-

public with sharing class JqueryTab 
{
public list<Account> lstAccount {get; set;}
public list<Contact> lstContact {get; set;}
public Contact objContact {get; set;}
public Opportunity objOpportunity {get; set;} 
public String strAccId {get; set;}
public boolean bRenderThePanel {get; set;}
 
public JqueryTab()
{
lstAccount = new List<Account>([Select Id,Name from Account]);
bRenderThePanel=false;
//lstContact = new List<Contact>([Select Id,Name from Contact]);
public void getRelatedContact()
{
system.debug('+++++++++++++++++++++++++++++'+strAccId);
lstContact = new List<Contact>([Select Id,Name from Contact where AccountId =:strAccId]);
system.debug('+++++++++++++++++++++++++++++'+lstContact);
bRenderThePanel=true;
}
}

 

Hi,

I have created a visualforce page where i've used standard controller as one of the custom object from my organisation.

On custom object , I've look up which has certain criteria defined. But when i use this Lookup as inputfield on Visualforce page, the look up window doesnt showing any records on it. The same look up filter works in Salesforce Native UI.

Can any one let me know why this is happening. Appreciatethe help.

Thanks in advance.
Dipak

Hi ,

 

I am trying to figure out if the "APPROVE" and "REJECT" buttons could be displayed inside the email notification that is being sent to approver during the approval process?

 

Appreciate if anyone code through somelight on this.

 

Thanks,
Sai

  • February 07, 2013
  • Like
  • 0