You need to sign in to do that
Don't have an account?

change visualforce page so I can edit records
Hi, I have a VF page that show 'Similar Leads' based on matching by email. Because in our org it is okay to have the same lead twice as they could be for different events. Any way I have a VF page with apex class that shows the 'similar leads'. Howvwer this just shows the leads, doesnt allow you to edit them. Can you suggest how this could be done? Code below:
Apex:
public class GetLeadsApexController {
private final Lead lead;
public GetLeadsApexController(ApexPages.StandardController stdController) {
if (!Test.isRunningTest()) {
stdController.addFields(new List<String>{'Name', 'Email', 'OwnerId', 'Status', 'Product_of_Interest__c'});
}
this.lead = (Lead)stdController.getRecord();
}
public List<Lead> getLeads () {
List<Lead> leads = [
SELECT Id, Name, Email, Status, OwnerId, Product_of_Interest__c FROM Lead WHERE Id != :lead.Id AND Email = :lead.Email
];
return leads;
}
}
VF Page:
<apex:page lightningStylesheets="true" standardController="Lead" extensions="GetLeadsApexController" tabStyle="Lead" sidebar="false">
<apex:pageBlock >
<apex:pageBlockTable value="{! leads }" var="ct" id="leads_list">
<apex:column value="{! ct.name}" />
<apex:column value="{! ct.email}" />
<apex:column value="{! ct.Product_of_Interest__c}" />
<apex:column value="{! ct.OwnerId}" />
<apex:column value="{! ct.Status}" />
<apex:inputCheckbox />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Many Thanks
Conor
Apex:
public class GetLeadsApexController {
private final Lead lead;
public GetLeadsApexController(ApexPages.StandardController stdController) {
if (!Test.isRunningTest()) {
stdController.addFields(new List<String>{'Name', 'Email', 'OwnerId', 'Status', 'Product_of_Interest__c'});
}
this.lead = (Lead)stdController.getRecord();
}
public List<Lead> getLeads () {
List<Lead> leads = [
SELECT Id, Name, Email, Status, OwnerId, Product_of_Interest__c FROM Lead WHERE Id != :lead.Id AND Email = :lead.Email
];
return leads;
}
}
VF Page:
<apex:page lightningStylesheets="true" standardController="Lead" extensions="GetLeadsApexController" tabStyle="Lead" sidebar="false">
<apex:pageBlock >
<apex:pageBlockTable value="{! leads }" var="ct" id="leads_list">
<apex:column value="{! ct.name}" />
<apex:column value="{! ct.email}" />
<apex:column value="{! ct.Product_of_Interest__c}" />
<apex:column value="{! ct.OwnerId}" />
<apex:column value="{! ct.Status}" />
<apex:inputCheckbox />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Many Thanks
Conor
Try below code
All Answers
Try below code