You need to sign in to do that
Don't have an account?
Rajashri
Pickup current Lead Id
Hi,
I have hardcoded the lead id in my code.Can anyone please tell me how to get the current lead Id.
I have hardcoded the leadid in my code and it works fine.
Below is my code..just need help in how to pickup the Lead Id dynamically like :camp.Id
public with sharing class singleListView {
public Campaign camp {get; set; }
public singleListView(ApexPages.StandardController controller) {
camp = (Campaign)controller.getRecord();
}
private List<Schema.Lead> CampaignMembers;
public List<Schema.Lead> getCampaignMembers() {
CampaignMembers=[Select Id,Name,(Select id, Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,LeadID,Lead.Phone,Lead.Email, Lastmodifieddate,Status,CampaignId,Campign_ID__c,Lead.MobilePhone From CampaignMembers where CampaignId =:camp.Id and Status != '' and LeadId != null),
(Select Subject, Id,lastModifiedDate From ActivityHistories where lastModifiedDate !=null and Subject !=null order by LastModifiedDate desc limit 1)
From Lead where Name !=NULL and Id='00Q90000008fA5OEAU' order by LastModifiedDate desc];
return CampaignMembers;
} }
I have hardcoded the lead id in my code.Can anyone please tell me how to get the current lead Id.
I have hardcoded the leadid in my code and it works fine.
Below is my code..just need help in how to pickup the Lead Id dynamically like :camp.Id
public with sharing class singleListView {
public Campaign camp {get; set; }
public singleListView(ApexPages.StandardController controller) {
camp = (Campaign)controller.getRecord();
}
private List<Schema.Lead> CampaignMembers;
public List<Schema.Lead> getCampaignMembers() {
CampaignMembers=[Select Id,Name,(Select id, Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,LeadID,Lead.Phone,Lead.Email, Lastmodifieddate,Status,CampaignId,Campign_ID__c,Lead.MobilePhone From CampaignMembers where CampaignId =:camp.Id and Status != '' and LeadId != null),
(Select Subject, Id,lastModifiedDate From ActivityHistories where lastModifiedDate !=null and Subject !=null order by LastModifiedDate desc limit 1)
From Lead where Name !=NULL and Id='00Q90000008fA5OEAU' order by LastModifiedDate desc];
return CampaignMembers;
} }
Can you tells us where and how are you trying to use this class?
A screen shot will convey a lot of info and also please use "Add Code Sample" button in the editor pallette (< > ).
Thanks,
Venkat
Below is my VF page code...
<apex:page StandardController="Campaign" extensions="singleListView">
<apex:form >
<apex:pageBlock title="Campaign Members Details" mode="maindetail">
<apex:pageBlockSection title="Campaign Members" id="cm3">
<apex:pageblocktable value="{!CampaignMembers}" var="cm">
<!-- <apex:column headerValue="Name">
<apex:outputfield value="{!cm.Name}"/>
</apex:column>-->
<apex:column >
<!-- <apex:outputLink value="{!$Page.somePage}?oppId={!opportunityFromController.Id}" target="_top">click here</apex:outputLink>-->
<!-- <apex:outputLink value="{!$Page.singleListView}" >Edit</apex:outputLink>-->
<apex:pageblocktable value="{!cm.CampaignMembers}" var="cpm">
<apex:column headerValue="Action">
<apex:outputLink value="{!$Page.Edit}" style="color:blue">Edit</apex:outputLink>
<apex:outputLink value="{!$Page.Delete}" style="color:blue">|Del</apex:outputLink>
</apex:column>
<apex:column headerValue="Status">
<apex:outputfield value="{!cpm.Status}" rendered="{!cpm.Status != null}"/>
</apex:column>
<apex:column headerValue="Name">
<apex:outputfield value="{!cpm.LeadID}" rendered="{!cpm.LeadID != null}"/>
</apex:column>
<apex:column headerValue="Phone">
<apex:outputfield value="{!cpm.Lead.Phone}" rendered="{!cpm.Lead.Phone != null}"/>
</apex:column>
<apex:column headerValue="Mobile">
<apex:outputfield value="{!cpm.Lead.MobilePhone}" />
</apex:column>
<apex:column headerValue="Email">
<apex:outputfield value="{!cpm.Lead.Email}" rendered="{!cpm.Lead.Email != null}"/>
</apex:column>
<apex:column headerValue="Last Modified Date">
<apex:outputfield value="{!cpm.lastmodifieddate}" rendered="{!cpm.lastmodifieddate != null}"/>
</apex:column>
</apex:pageblocktable>
</apex:column>
<apex:column >
<apex:pageblocktable value="{!cm.ActivityHistories}" var="tm">
<apex:column headerValue="Subject">
<apex:outputfield value="{!tm.Subject}" rendered="{!tm.Subject != null}"/>
<!--<apex:outputText value="{! IF((tm.Subject== null), 'NA', tm.Subject) }"/>-->
</apex:column>
<apex:column headerValue="Last Modified Date">
<apex:outputfield value="{!tm.LastmodifiedDate}" rendered="{!tm.LastmodifiedDate != null}"/>
</apex:column>
</apex:pageblocktable>
</apex:column>
</apex:pageblocktable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Below is my VF page code...
<apex:page StandardController="Campaign" extensions="singleListView">
<apex:form >
<apex:pageBlock title="Campaign Members Details" mode="maindetail">
<apex:pageBlockSection title="Campaign Members" id="cm3">
<apex:pageblocktable value="{!CampaignMembers}" var="cm">
<!-- <apex:column headerValue="Name">
<apex:outputfield value="{!cm.Name}"/>
</apex:column>-->
<apex:column >
<!-- <apex:outputLink value="{!$Page.somePage}?oppId={!opportunityFromController.Id}" target="_top">click here</apex:outputLink>-->
<!-- <apex:outputLink value="{!$Page.singleListView}" >Edit</apex:outputLink>-->
<apex:pageblocktable value="{!cm.CampaignMembers}" var="cpm">
<apex:column headerValue="Action">
<apex:outputLink value="{!$Page.Edit}" style="color:blue">Edit</apex:outputLink>
<apex:outputLink value="{!$Page.Delete}" style="color:blue">|Del</apex:outputLink>
</apex:column>
<apex:column headerValue="Status">
<apex:outputfield value="{!cpm.Status}" rendered="{!cpm.Status != null}"/>
</apex:column>
<apex:column headerValue="Name">
<apex:outputfield value="{!cpm.LeadID}" rendered="{!cpm.LeadID != null}"/>
</apex:column>
<apex:column headerValue="Phone">
<apex:outputfield value="{!cpm.Lead.Phone}" rendered="{!cpm.Lead.Phone != null}"/>
</apex:column>
<apex:column headerValue="Mobile">
<apex:outputfield value="{!cpm.Lead.MobilePhone}" />
</apex:column>
<apex:column headerValue="Email">
<apex:outputfield value="{!cpm.Lead.Email}" rendered="{!cpm.Lead.Email != null}"/>
</apex:column>
<apex:column headerValue="Last Modified Date">
<apex:outputfield value="{!cpm.lastmodifieddate}" rendered="{!cpm.lastmodifieddate != null}"/>
</apex:column>
</apex:pageblocktable>
</apex:column>
<apex:column >
<apex:pageblocktable value="{!cm.ActivityHistories}" var="tm">
<apex:column headerValue="Subject">
<apex:outputfield value="{!tm.Subject}" rendered="{!tm.Subject != null}"/>
<!--<apex:outputText value="{! IF((tm.Subject== null), 'NA', tm.Subject) }"/>-->
</apex:column>
<apex:column headerValue="Last Modified Date">
<apex:outputfield value="{!tm.LastmodifiedDate}" rendered="{!tm.LastmodifiedDate != null}"/>
</apex:column>
</apex:pageblocktable>
</apex:column>
</apex:pageblocktable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- getCampaignMemebers() return type is Lead where as you are returning a List. I believe, you should return a list as this method is used in the pageblock table in your VF page
- A Campaign can have Leads or Contacts as members. You should return both. If want to show Lead/Contact details along with the member record, you cannot return that as part of the member record. You may want to have an inline class with member details as well as the activityhistory. Create a list of this new inline class type and iterate over it.
- Campaign Members is a child of Campaign and when you inline a VF page on Campaign Page layout you will not get Campaign member as a param, only the Campaign.
Thanks,Venkat
https://help.salesforce.com/apex/HTViewSolution?id=000005105&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000005105&language=en_US)
http://blog.jeffdouglas.com/2009/05/08/inline-visualforce-pages-with-standard-page-layouts/
Apex inner classes:
http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex_visualforce_5.htm