Apex class to save custom object data


i2

Save Lead with custom fields:

public PageReference saveLeadData() { 
Lead l = new Lead(
 P_PERSONID__c = 6663649,
 ROLEID__c = 5898589,
 P_PROJECTID__c = 10796447,
 Salutation = 'Mr.',
 FirstName = 'saket',
 LastName = 'saraf',
 Title = '',
 Phone = '98920000',
 Email = 'saket.saraf@gmail.com',
 Street = 'Land Adj 23 Lisle Street',
 City = 'Loughborough',
 State = 'Leicestershire',
 PostalCode = 'LE11 1AW',
 Fax = '',
 WebSite = '',
 LeadSource = 'Reserved'
 );

try {
    insert l; // inserts the new record into the database
} catch (Exception e) {
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error,

     'Error adding Reserve List.'));
return null; //Use Page.newPagename
}
return null;   //Use Page.newPagename
} 

Happy Coding……..

3367total visits,4visits today

Leave a Reply

Your email address will not be published. Required fields are marked *