You need to sign in to do that
Don't have an account?
Ravi kumar 292
ContactId is null
Hi all,
This is my code.
String LeadId=ApexPages.currentPage().getParameters().get('id');
Lead l =[select id,Amount_in_Rs__c,Status,Application_Id__c from Lead where id=:LeadId];
system.debug('Lead id--'+l.id);
Contact c = [select id,FirstName,LastName from Contact where id=:l.id];
system.debug('contact id --'+c.id);
I am getting the Lead id from the lead query but am not getting the contact id which is related to the lead. I have one contact for the lead.
Help on this.
Thanks,
This is my code.
String LeadId=ApexPages.currentPage().getParameters().get('id');
Lead l =[select id,Amount_in_Rs__c,Status,Application_Id__c from Lead where id=:LeadId];
system.debug('Lead id--'+l.id);
Contact c = [select id,FirstName,LastName from Contact where id=:l.id];
system.debug('contact id --'+c.id);
I am getting the Lead id from the lead query but am not getting the contact id which is related to the lead. I have one contact for the lead.
Help on this.
Thanks,
Contact c = [select id,FirstName,LastName from Contact where id=:l.id];
Here you are using the L.Id which is wrong.
Regards,
Mahesh
If you can explain us exactly what you are trying to achieve here then it will be easy to provide the better solution.
Contact Id will not be equal to l.Id.
Regards,
Mahesh
Sring LeadId=ApexPages.currentPage().getParameters().get('id');
Lead l =[select id,Amount_in_Rs__c,Status,Application_Id__c from Lead where id=:LeadId];
system.debug('Lead id--'+l.id);
Contact c = [select id,FirstName,LastName from Contact where id=:l.id]; // You are using lead id here which will never be equal to Contcact ID
system.debug('contact id --'+c.id);
If you want to fatch the related contact then query should one lastName or any other field like below
Contact c = [select id,FirstName,LastName from Contact where LastName =:l.LastName];
system.debug('contact id --'+c.id);
Let us know if this will help you
Thanks
Amit Chaudhary