• 123_P
  • NEWBIE
  • 30 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
controller=======
public with sharing class Searchclass {

    public list<Account> acc {get;set;}
    public list<Contact> conList{get;set;}
    public string searchstring {get;set;} 
    public Boolean showSection2{get;set;}


    public Searchclass(ApexPages.StandardController controller) {
     
    }  
    public void search(){  
        if(searchstring != null && searchstring != '' ){
        showSection2= true;           
        string searchquery='select Name,AccountNumber,BillingCity,Industry from Account where Name like \'%'+searchstring+'%\'';       
        string searchquery1='select Title,Department,Phone,FirstName from Contact where Account.Name like \'%'+searchstring+'%\'';
        acc= Database.query(searchquery);
        system.debug('acc'+acc); 
        conList= Database.query(searchquery1); 
        system.debug('conList'+conList);
        }
    }
}

vf page===========
<apex:page standardController="Account"  extensions="Searchclass" >  
<apex:slds />
<apex:form > 
<apex:pageBlock >
  <apex:pageBlockSection columns="1" >
      <apex:inputText value="{!searchstring}" />
      <apex:commandButton value="Search records" action="{!search}"/>
    <apex:pageBlockTable value="{!acc}" var="c">
         <apex:column headerValue="Account" />        
         <apex:column value="{!c.Name}" style="width:250px"/>  
    </apex:pageBlockTable>   
    <apex:pageblockTable value="{!acc}" var="c">        
        <apex:column value="{!c.BillingCity}" />
        <apex:column value="{!c.AccountNumber}" style="width:250px"/>
        <apex:column value="{!c.Industry}" style="width:250px"/>
    </apex:pageblockTable>
    <apex:pageBlockTable value="{!conList}" var="con">
        <!--apex:column headerValue="Contact"/-->        
        <apex:column value="{!con.FirstName}" headerValue="Contact" />
        <apex:column value="{!con.Title}" style="width:250px" />
        <apex:column value="{!con.Department}" style="width:250px"/>
        <apex:column value="{!con.Phone}" style="width:250px"/>             
    </apex:pageBlockTable>                 
  </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
 
  • September 17, 2018
  • Like
  • 0
3) Contact must be saved using this dialog along with Photo Upload option. That photo must be saved in attachment for that contact and must be visible when the dialog box open for that record. 
I have done all just i want to add photo in below code according to requirement
VF page:===========
<apex:page Controller="JqueryTableThroughVf" >
    <head>
        <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" /> 
           
        <script>
            <!--j$ = jQuery.noConflict();-->
            $(document).ready( function () {
                var contactTable = $('[id$="contacttable"]').DataTable({

                });
              
                $("#formid").hide();
                $('#a1').click(function(){
                $("#formid").show();
                
                });
                
                $('#closeButton').click(function(){
                $('#formid').hide();
                });

             });
         function myFunc(id){
             console.log(id);
            hold(id);
              $("#formid").show();
         }
            
        </script> 
        
      
    </head>
    <style type="text/css">
        .custPopup{
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;            
            width: 600px;
            margin-left: -350px;
            top:120px;
        }
        .popupBackground{
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 20);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }
    </style>
        <apex:form id="fd">
            <apex:actionFunction action="{!call}" name="hold"  rerender="dd">
            <apex:param id="aname" name="Idr" value="" />
            </apex:actionFunction>
            
        </apex:form>
        <body>
     <apex:form id="aa">
        <table id="contacttable" class="display">
            <thead>
                <tr>
                    <th>Account</th>
                    <th>First Name</th>
                    <th>Last Name</th>
                    <th>Phone</th>
                </tr>
            </thead>
            <tbody>
                <apex:repeat value="{!contactList}" var="contact">
                    <tr>
                        <td>{!contact.Account.Name}</td>
                        <td onclick="myFunc('{!contact.Id}'); return false;">{!contact.FirstName}</td>
                        <td>{!contact.LastName}</td>
                        <td>{!contact.Phone}</td>
                    </tr>                                  
                </apex:repeat>
            </tbody>          
        </table> 
          </apex:form>
        <div id="formid">
            <apex:outputPanel id="tstpopup"  >
            <apex:outputPanel styleClass="popupBackground" layout="block" />
            <apex:outputPanel styleClass="custPopup" layout="block" >
     <apex:form id="dd">
        <apex:pageBlock title="My Content" mode="edit">
            
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!con.account.name}"/>
                <apex:inputField value="{!con.firstname}"/>
                <apex:inputField value="{!con.lastname}"/>
                <apex:inputField value="{!con.phone}"/>
                Upload Photo<apex:commandButton  value="Upload" action="{!upload}"/>
                <apex:inputFile  value="{!attach.body}" filename="{!attach.name}"></apex:inputFile>                                
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!updateContact}" reRender="dd" >
                <apex:param name="con" assignTo="{!newcon}" value="con" />
                </apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>

            <button type="button" id='closeButton'>Close</button>
            </apex:outputPanel>
            </apex:outputPanel>
        </div>                      
    </body>
</apex:page>

Controller==============
public class JqueryTableThroughVf {
    public boolean displayPopup {get; set;}
    public Contact con {get;set;} 
    public String newcon{get;set;}
     
    public List<Contact> contactList {
        get {
            if (contactList == null) {
                contactList = [SELECT Account.Name, FirstName, LastName, Phone FROM Contact limit 1000];
            }
            return contactList;
        }
        set;
    }
    
    
    public void call(){
        contact conn= new contact();
         string passedParam1 = Apexpages.currentPage().getParameters().get('Idr');
        con = [select Account.Name, firstname,lastname, phone from contact where id =: passedParam1];
       //con = conn.firstname;
        System.debug('@@  ');
    }
    public void updateContact(){
        System.debug('inupdate');
        //Contact con = Apexpages.currentPage().getParameters().get('con');
        system.debug('ddd   ' +newcon);
        system.debug('obj  '+con);        
        update con;

    }
    
  
}


 
  • August 30, 2018
  • Like
  • 0
Handler--------------------------

public class UpdateAccAddressTriggerHandler{
    public static void changeAccAddress(list<contact> contList){
        set<Id> AcctIds=new set<Id>();
        list<Account> accList=new list<Account>();
        map<Id,Contact> contMap = new map<Id,Contact>();
        
        for(Contact con:contList){
            AcctIds.add(con.AccountId);       
        }
        
        for(Contact con:[Select Id,AccountId, MailingStreet,MailingCity, MailingState, MailingCountry,  MailingPostalCode,LastModifiedDate  from Contact 
        WHERE AccountId IN:AcctIds order by LastModifiedDate Desc limit 1]){
             if(!contMap.containskey(con.accountId)){
             contMap.put(con.AccountId,con); 
             }           
        }
        
        for(Account acc:[select id,BillingCity,BillingStreet,BillingCountry,BillingPostalCode from Account where id IN:AcctIds]){          
            Contact con =contMap.get(acc.id);
            acc.BillingStreet=con.MailingStreet; 
            acc.BillingCity=con.MailingCity;
            acc.BillingState=con.MailingState;
            acc.BillingPostalCode=con.MailingPostalCode;
            acc.BillingCountry=con.MailingCountry;                   
            accList.add(acc);
       }                
       update accList;        
   }
}

Trigger--------------------------
trigger updateAccAddressTrigger on Contact (after insert,after update) {
    if(Trigger.isAfter){
        UpdateAccAddressTriggerHandler.changeAccAddress(Trigger.New);
    
    }
}
  • August 07, 2018
  • Like
  • 0
Create object : Candidate__c
Fields : (All Text fields)
First Name
Last Name
Email
Brokerage
Manage Brokerage
Candidate Status (Webinar - Attended , Webinar -Not Attended)
User Created ( checkbox)


On insert:
1. Create Account if Brokerage !=null
2. Create another account if Manage Brokerage != null and set parentId = Brokerage account id (created in 1 point)
3. Create new contact record and set accountId = Manage Brokerage account id (created in 2 point)
   create new field candidate__c(lookup) on contact and fill it with Condidate__c record id
4. Create task record for contact record (created in point 3)
Task.WhoId = contactId
Task.WhatId = Candidate__c
Task.Subject = 'Portal Contact Setup';
 
  • July 19, 2018
  • Like
  • 1
Create object : Candidate__c
Fields : (All Text fields)
First Name
Last Name
Email
Brokerage
Manage Brokerage
Candidate Status (Webinar - Attended , Webinar -Not Attended)
User Created ( checkbox)


On insert:
1. Create Account if Brokerage !=null
2. Create another account if Manage Brokerage != null and set parentId = Brokerage account id (created in 1 point)
3. Create new contact record and set accountId = Manage Brokerage account id (created in 2 point)
   create new field candidate__c(lookup) on contact and fill it with Condidate__c record id
4. Create task record for contact record (created in point 3)
Task.WhoId = contactId
Task.WhatId = Candidate__c
Task.Subject = 'Portal Contact Setup';
 
  • July 19, 2018
  • Like
  • 1
controller=======
public with sharing class Searchclass {

    public list<Account> acc {get;set;}
    public list<Contact> conList{get;set;}
    public string searchstring {get;set;} 
    public Boolean showSection2{get;set;}


    public Searchclass(ApexPages.StandardController controller) {
     
    }  
    public void search(){  
        if(searchstring != null && searchstring != '' ){
        showSection2= true;           
        string searchquery='select Name,AccountNumber,BillingCity,Industry from Account where Name like \'%'+searchstring+'%\'';       
        string searchquery1='select Title,Department,Phone,FirstName from Contact where Account.Name like \'%'+searchstring+'%\'';
        acc= Database.query(searchquery);
        system.debug('acc'+acc); 
        conList= Database.query(searchquery1); 
        system.debug('conList'+conList);
        }
    }
}

vf page===========
<apex:page standardController="Account"  extensions="Searchclass" >  
<apex:slds />
<apex:form > 
<apex:pageBlock >
  <apex:pageBlockSection columns="1" >
      <apex:inputText value="{!searchstring}" />
      <apex:commandButton value="Search records" action="{!search}"/>
    <apex:pageBlockTable value="{!acc}" var="c">
         <apex:column headerValue="Account" />        
         <apex:column value="{!c.Name}" style="width:250px"/>  
    </apex:pageBlockTable>   
    <apex:pageblockTable value="{!acc}" var="c">        
        <apex:column value="{!c.BillingCity}" />
        <apex:column value="{!c.AccountNumber}" style="width:250px"/>
        <apex:column value="{!c.Industry}" style="width:250px"/>
    </apex:pageblockTable>
    <apex:pageBlockTable value="{!conList}" var="con">
        <!--apex:column headerValue="Contact"/-->        
        <apex:column value="{!con.FirstName}" headerValue="Contact" />
        <apex:column value="{!con.Title}" style="width:250px" />
        <apex:column value="{!con.Department}" style="width:250px"/>
        <apex:column value="{!con.Phone}" style="width:250px"/>             
    </apex:pageBlockTable>                 
  </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
 
  • September 17, 2018
  • Like
  • 0
3) Contact must be saved using this dialog along with Photo Upload option. That photo must be saved in attachment for that contact and must be visible when the dialog box open for that record. 
I have done all just i want to add photo in below code according to requirement
VF page:===========
<apex:page Controller="JqueryTableThroughVf" >
    <head>
        <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" /> 
           
        <script>
            <!--j$ = jQuery.noConflict();-->
            $(document).ready( function () {
                var contactTable = $('[id$="contacttable"]').DataTable({

                });
              
                $("#formid").hide();
                $('#a1').click(function(){
                $("#formid").show();
                
                });
                
                $('#closeButton').click(function(){
                $('#formid').hide();
                });

             });
         function myFunc(id){
             console.log(id);
            hold(id);
              $("#formid").show();
         }
            
        </script> 
        
      
    </head>
    <style type="text/css">
        .custPopup{
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;            
            width: 600px;
            margin-left: -350px;
            top:120px;
        }
        .popupBackground{
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 20);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }
    </style>
        <apex:form id="fd">
            <apex:actionFunction action="{!call}" name="hold"  rerender="dd">
            <apex:param id="aname" name="Idr" value="" />
            </apex:actionFunction>
            
        </apex:form>
        <body>
     <apex:form id="aa">
        <table id="contacttable" class="display">
            <thead>
                <tr>
                    <th>Account</th>
                    <th>First Name</th>
                    <th>Last Name</th>
                    <th>Phone</th>
                </tr>
            </thead>
            <tbody>
                <apex:repeat value="{!contactList}" var="contact">
                    <tr>
                        <td>{!contact.Account.Name}</td>
                        <td onclick="myFunc('{!contact.Id}'); return false;">{!contact.FirstName}</td>
                        <td>{!contact.LastName}</td>
                        <td>{!contact.Phone}</td>
                    </tr>                                  
                </apex:repeat>
            </tbody>          
        </table> 
          </apex:form>
        <div id="formid">
            <apex:outputPanel id="tstpopup"  >
            <apex:outputPanel styleClass="popupBackground" layout="block" />
            <apex:outputPanel styleClass="custPopup" layout="block" >
     <apex:form id="dd">
        <apex:pageBlock title="My Content" mode="edit">
            
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!con.account.name}"/>
                <apex:inputField value="{!con.firstname}"/>
                <apex:inputField value="{!con.lastname}"/>
                <apex:inputField value="{!con.phone}"/>
                Upload Photo<apex:commandButton  value="Upload" action="{!upload}"/>
                <apex:inputFile  value="{!attach.body}" filename="{!attach.name}"></apex:inputFile>                                
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!updateContact}" reRender="dd" >
                <apex:param name="con" assignTo="{!newcon}" value="con" />
                </apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>

            <button type="button" id='closeButton'>Close</button>
            </apex:outputPanel>
            </apex:outputPanel>
        </div>                      
    </body>
</apex:page>

Controller==============
public class JqueryTableThroughVf {
    public boolean displayPopup {get; set;}
    public Contact con {get;set;} 
    public String newcon{get;set;}
     
    public List<Contact> contactList {
        get {
            if (contactList == null) {
                contactList = [SELECT Account.Name, FirstName, LastName, Phone FROM Contact limit 1000];
            }
            return contactList;
        }
        set;
    }
    
    
    public void call(){
        contact conn= new contact();
         string passedParam1 = Apexpages.currentPage().getParameters().get('Idr');
        con = [select Account.Name, firstname,lastname, phone from contact where id =: passedParam1];
       //con = conn.firstname;
        System.debug('@@  ');
    }
    public void updateContact(){
        System.debug('inupdate');
        //Contact con = Apexpages.currentPage().getParameters().get('con');
        system.debug('ddd   ' +newcon);
        system.debug('obj  '+con);        
        update con;

    }
    
  
}


 
  • August 30, 2018
  • Like
  • 0
Create object : Candidate__c
Fields : (All Text fields)
First Name
Last Name
Email
Brokerage
Manage Brokerage
Candidate Status (Webinar - Attended , Webinar -Not Attended)
User Created ( checkbox)


On insert:
1. Create Account if Brokerage !=null
2. Create another account if Manage Brokerage != null and set parentId = Brokerage account id (created in 1 point)
3. Create new contact record and set accountId = Manage Brokerage account id (created in 2 point)
   create new field candidate__c(lookup) on contact and fill it with Condidate__c record id
4. Create task record for contact record (created in point 3)
Task.WhoId = contactId
Task.WhatId = Candidate__c
Task.Subject = 'Portal Contact Setup';
 
  • July 19, 2018
  • Like
  • 1