• Naveen Ashok Sirivella
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 10
    Replies
Hi All,

I want to update campaign name,primary product on Lead record .

Please find the below code

Public static void After_UpdateLeadCampaignDetails()
      {
          List<CampaignMember> camlist = (List<CampaignMember>)trigger.new;
          System.debug('Values in the camlist:========================>'+camlist);
          Set<Id> leadid = new Set<Id>();
          
          List<Lead> leadlist = new List<Lead>();
          for(CampaignMember cm:camlist)
          {
              Lead lea = new Lead();
                if(lea.id == cm.LeadId)
                {
                    lea.Campaign_Name__c = cm.Campaign.name;
                    leadlist.add(lea);
                }
          }
          
          database.update(leadlist);
          
      }

Please help any one
Hi All,

I have 2 years of exp in salesforce development.Currently i am working on testing project.

I have forget my coding knowlege.

I am again started learning salesforce coding can any one please help me to increase my coding knowledge.

Thanks
Naveen Ashok S
Hi All,

I am new to salesforce.
I have on requirment.When i click on "Show All leads" button on that time only records need to display with new page block.
Below are my code:
-----------------------------------
VF page
----------------------
<apex:page standardController="Lead" Extensions="DisplayingListofrecords_Controller">

<apex:form >
  <apex:pageBlock title="For buttons">
       <apex:commandButton action="{!ShowLeads}" value="Show Leads" reRender="Details"/>
  </apex:pageBlock>
</apex:form>
<apex:outputPanel id="Details">
<apex:actionStatus startText="Requesting............">
  <apex:pageBlock title="Displaying List of accounts" id="Showlistofleads" rendered="false">
    <apex:dataTable value="{!leadlist}" var="a" cellpadding="4" border="1">
        <apex:column >
              <apex:facet name="header">Name</apex:facet>
              {!a.Name}
        </apex:column>  
        <apex:column >
              <apex:facet name="header">Company</apex:facet>
              {!a.Company}
        </apex:column>  
        <apex:column >
              <apex:facet name="header">Status</apex:facet>
              {!a.Status}
        </apex:column>  
        <apex:column >
              <apex:facet name="header">Industry</apex:facet>
              {!a.Industry}
        </apex:column>  
        <apex:column >
              <apex:facet name="header">Email</apex:facet>
              {!a.Email}
        </apex:column>  
        <apex:column >
              <apex:facet name="header">LeadSource</apex:facet>
              {!a.LeadSource}
        </apex:column>  
        <apex:column >
              <apex:facet name="header">Lead Score</apex:facet>
              {!a.Lead_Score__c}
        </apex:column>          
    </apex:dataTable>
</apex:pageBlock>
</apex:actionStatus>
</apex:outputPanel>
</apex:page>
Controller
-------------------
public with sharing class DisplayingListofrecords_Controller {

    Public List<Lead> leadlist {get;set;}
    public DisplayingListofrecords_Controller(ApexPages.StandardController controller) {
     
   
    }
    
    public PageReference ShowLeads()
    {
         leadlist = [select Name,Company,Status,Industry,Email,LeadSource,Lead_Score__c from lead];
         
         return null;
    }

}