You need to sign in to do that
Don't have an account?
Getting This Error While Validating in Production during Production "System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Your lead is missing a field mapping for the fields. For help, talk with your adm"
My Code:
Apex Class:
--------------------
public class LookupApexAuraServices {
@AuraEnabled
public static List<Lead> ChooseExistingAcc(string leadId, string accountId){
List<Lead> convertedList = new List<Lead>();
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(leadId);
lc.setAccountId(accountId);
lc.setDoNotCreateOpportunity(true);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
convertedList = [SELECT Id, Name, RecordTypeId,
IsConverted, ConvertedAccountId, ConvertedContactId
FROM Lead where id =:leadId limit 1];
system.debug('convertedList : '+convertedList);
return convertedList;
}
}
Test Class:
------------------
@IsTest
public class LookupApexAuraServices_Test {
private class RestMock implements HttpCalloutMock {
public HTTPResponse respond(HTTPRequest req) {
String fullJson = 'your Json Response';
HTTPResponse res = new HTTPResponse();
res.setHeader('Content-Type', 'text/json');
res.setBody(fullJson);
res.setStatusCode(200);
return res;
}
}
static testmethod void testChooseExistingAcc(){
Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Person Account').getRecordTypeId();
List<Account> acclist = new List<Account>();
Account a = new Account();
a.RecordTypeId = devRecordTypeId;
a.FirstName = 'Accfname';
a.LastName = 'AccTestLName';
acclist.add(a);
insert acclist;
List<Lead> leadlst = new List<Lead>();
lead l = new lead();
l.FirstName = 'testf';
l.LastName = 'testlast';
l.Email = 'asdfg@gmail.com';
leadlst.add(l);
lead ld = new lead();
ld.FirstName = 'testfirst';
ld.LastName = 'testlast';
ld.Email = 'asdf@gmail.com';
leadlst.add(ld);
insert leadlst;
Test.startTest();
Test.setMock(HttpCalloutMock.class, new RestMock());
LookupApexAuraServices.ChooseExistingAcc(ld.Id, a.Id);
Test.stopTest();
}
}
Code COverage is 95% but while deployment getting this error
Getting This Error While Validating in Production during Production "System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Your lead is missing a field mapping for the fields. For help, talk with your admin" ....?
Please Help Me guys.
try below code,
Make sure mapping is good.
you can take reference from below link about lead mapping.
https://help.salesforce.com/s/articleView?id=sf.customize_mapleads.htm&type=5
if above info is helpful to you ,don't forget to mark it as best answer.
Thank you
Thank You!