You need to sign in to do that
Don't have an account?
apex class auto convert lead error on deploy i cant make the deploy
System.QueryException: List has no rows for assignment to SObject
Stack Trace: Class.MyProfilePageController.testSave: line 78, column 1
apex class
Public class AutoConvertLeads
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
You Have two option now
All Answers
What’s not obvious is that it also assumes that exactly one row is returned!
It is highly likely to occur for any custom objects you create, especially when a WHERE statement is used that might return zero rows, such as: It would be safer to do the following:
I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D
You Have two option now
Hey Raj
Thanks for your answer it is me first time on deploy apex class and i don't know how to make the "Deploy with only by running the specific test class"
@Ramesh Depaiah the code you added the full code looks like this its this ok
Public class AutoConvert
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE); //Remove this line if you want to create an opportunity from Lead Conversion
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
Thanks
and pass your test class