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

List has no rows for assignment to SObject
here is my Apex class
global class Lead_Conversion { (here the base on the id query is fetched but while executing the query its raising this error plz help me out)
My Test Class is ===============
@isTest (SeeAllData = true)
|
Dear cherrlin,
I have got the solution
i have done the mistake where i have no access to that object now i have run assystem admin which i have achived
but error which returnrd is incorrect...
Thanks a lot..Have a nice day..
Jaya.
All Answers
In this situation i'll first check all the queries are return values with an hardcoded id first.
If its running without any error then i'll check with leadid.
In this you commented some code send me the exact code. i'll try it.
hi
Yes it is possible to send id form test class also.
You can also check that id value when you run the test class.
download the log and check it.
Dear cherrlin,
Id is getting passed but the issue is when i trying to query with that id iam unable to fetch the record there iam getting this exception
System.QueryException: List has no rows for assignment to SObject
but befor trying to retrive i printing the ID its getting displayed
1)Lead testleadobj=newLead(LastName='jakc',Company='jakc',Status='Qualified',Company_segment__c='SME A',Lead_Type__c='Company',Lead_Region__c='AP',Product_Type__c='TTL',Product__c=prdSME.Id,SME_TTL_Product__c=prdSME.Id,OwnerId=semiAdmin.Id,RecordTypeId=SmeLeadrecordtype.getRecordTypeId());
2)insert testleadobj;
3)system.debug('=====testleadobj.Id===='+testleadobj.Id);
4)Lead leds =[select LastName,Company,Status fromLeadwhere Id=:testleadobj.id];
in the above code till 3rd line its executing after executing 4 line iam geting the exception
System.QueryException: List has no rows for assignment to SObject
plz help me out
Thanks,
Jaya
Yes you wont be getting it because all the operations which you done in test class are temporary. It wont be commited in the production or sandbox
and also there is also no data present in the org with respect to that id which you got after inserting the record.
Solution is use annotation @isTest(SeeAllData == true) which you have also done it
and use the lead id which is already present in Production or Sandbox.
My case based on the inserted record Id i need to run the apex calss so how can i achive the Code coverage for the apex class
Thanks,
jaya
Just do one thing in the test class
do this
Lead_Conversion.convertLead(testleadobj.Id);
in place of testleadobj.id you provide the hardcoded id which is already present your sandbox or production.
and run the test class
Even with the hardcoded iam unable to achive this.
Thanks,
Jaya
Lead_Conversion.convertLead('your id');
Same thing you have done ???
right??
any errors?????
Yeah Same i have done and same error iam getting List has no rows for assignment to SObject
Thanks,
Jaya
Even i have tried by retriving the existing data on leads and sending the lead id to the Lead_conversion class
but retriving the existing leads itself its giving zero records as test case doesnt pick the Saleforce database records i think so
Thanks,
JAya
Does the id which you gave has any respective lead record in production?
Yeah iam having the record..
Thanks,
Jaya
even when i trying to get exists data iam geting zero records here is log
12:55:21.386 (3386733000)|SOQL_EXECUTE_BEGIN|[46]|Aggregations:0|select Id, Company, LastName from Lead
12:55:21.491 (3491856000)|SOQL_EXECUTE_END|[46]|Rows:0
12:55:21.492 (3492214000)|USER_DEBUG|[48]|DEBUG|=======lldSize======0
Thanks
Jaya
When you mention @isTest(SeeAllData == true)
You can access you database records in test class.
Dear cherrlin,
I have got the solution
i have done the mistake where i have no access to that object now i have run assystem admin which i have achived
but error which returnrd is incorrect...
Thanks a lot..Have a nice day..
Jaya.