You need to sign in to do that
Don't have an account?
Create Selectable SObject Table for Editing
Hi All,
I have a requirement to create a VF page showing Leads and Contacts that have a hand-off date from the marketing team to the sales team in a specific time range in a table similar to what is described in the Force.com Cookbook http://developer.force.com/cookbook/recipe/selectable-sobjects-for-use-with-datatables-and-checkboxes.
I'm not sure how to bring both leads and contacts into the same view - I understand how to select the leads/contacts but I'm not clear how to get them both into the same list and how to put a date range selector (I can use relative dates such as last week, last month as well as specific date ranges) for the user to select what items they want to see.
I have a query that finds the leads and contacts I'm looking for and puts them into a list, but am not sure how to access the for the records?
Here is the code I have so far:
public with sharing class leadContactCombinedView{ private SObject record; public Boolean selected{get; set;} public List<leadContactCombinedView> listLeadContact {get;set;} // Universal constructor for any SalesForce object type public leadContactCombinedView(SObject obj) { record = obj; selected = false; } public leadContactCombinedView(){ } // Getter for Lead public Lead getLead() { return (Lead)record; } // Getter for Contact public Contact getContact() { return (Contact)record; } public List<leadContactCombinedView> generateListLeadContact(){ for(Lead l : [SELECT id, Website, Title, Street, Status, State, PostalCode, Phone, NumberOfEmployees, MobilePhone, LeadSource, LastName, Industry, HasOptedOutOfEmail, FirstName, Email, Description, Country, Company, City, OwnerID, Primary_Campaign__c, Hand_off_Date__c FROM Lead WHERE Status = 'Open'])
{ leadContactCombinedView leadItem = new leadContactCombinedView(l); this.ListLeadContact.add(leadItem); } for(Contact c : [SELECT id, Account.Website, Title, Account.BillingStreet, Contact_Status__c, Account.BillingState, Account.BillingPostalCode, Phone, account.NumberOfEmployees, MobilePhone, LeadSource, LastName, Account.Industry, HasOptedOutofEmail, FirstName, Email, Account.Description, Account.BillingCountry, Account.Name, Account.BillingCity, OwnerId, Primary_Campaign__c, Hand_off_Date__c, AccountId FROM Contact WHERE Contact_Status__c = 'Open']){ leadContactCombinedView contactItem = new leadContactCombinedView(c); this.ListLeadContact.add(contactItem); } return listLeadContact; } public List<leadContactCombinedView> getListLeadContact(){ return listLeadContact; } }
Hi,
You can achieve this using wrapper class, Below code is for an example and you can write it according to your requirements,
Apex Class,
Visual force,