You need to sign in to do that
Don't have an account?
Sheila Rashad
Reason: Apex trigger LeadConvert caused an unexpected exception, contact your administrator: LeadConvert: execution of AfterInsert
Hello everone, I need help on the following error message:
Reason: Apex trigger LeadConvert caused an unexpected exception, contact your administrator: LeadConvert: execution of AfterInsert
caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Your lead is missing a field mapping for the Pet Primary Caregiver,Household Allergies,Household Pets,Top Dogg K9 Exposure fields.
LeadConvert Trigger:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
trigger LeadConvert on Lead (after insert) {
ID acctID, ContID;
/* Get the Id and MasterLabel from LeadStatus object */
LeadStatus convertStatus = [ select Id, MasterLabel from LeadStatus where IsConverted = true limit 1 ];
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
for (Lead lead: Trigger.new) {
/* if (!lead.isConverted && lead.WebForm__c == 'Free Trial') { */
try {
Account acct = new Account(Name=lead.LastName + ' Household', recordtypeid = '0123i000000paRjAAI');
insert acct;
// Once the account is inserted, the sObject will be populated with an ID. Get this ID.
acctID = acct.ID;
Contact cont = new Contact( Contact_type__c='Applicant', AccountId=acctID);
insert cont;
contID = cont.ID;
} catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());
}
if (!lead.isConverted) {
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);
//String oppName = lead.Name;
//lc.setOpportunityName(oppName);
lc.setAccountId(acctID);
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
//leadConverts.add(lc);
}
}
//if (!leadConverts.isEmpty()) {
//List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
Not sure if I should make these fields not required on the Salesforce side to prevent error or deactivate the trigger. Also discovered that a blank application can be submitted which should not be the case. Please advise how to remove the error message and if it should be addressed on the application side on the website or the Salesforce side.
Reason: Apex trigger LeadConvert caused an unexpected exception, contact your administrator: LeadConvert: execution of AfterInsert
caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Your lead is missing a field mapping for the Pet Primary Caregiver,Household Allergies,Household Pets,Top Dogg K9 Exposure fields.
LeadConvert Trigger:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
trigger LeadConvert on Lead (after insert) {
ID acctID, ContID;
/* Get the Id and MasterLabel from LeadStatus object */
LeadStatus convertStatus = [ select Id, MasterLabel from LeadStatus where IsConverted = true limit 1 ];
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
for (Lead lead: Trigger.new) {
/* if (!lead.isConverted && lead.WebForm__c == 'Free Trial') { */
try {
Account acct = new Account(Name=lead.LastName + ' Household', recordtypeid = '0123i000000paRjAAI');
insert acct;
// Once the account is inserted, the sObject will be populated with an ID. Get this ID.
acctID = acct.ID;
Contact cont = new Contact( Contact_type__c='Applicant', AccountId=acctID);
insert cont;
contID = cont.ID;
} catch(DmlException e) {
System.debug('An unexpected error has occurred: ' + e.getMessage());
}
if (!lead.isConverted) {
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(lead.Id);
//String oppName = lead.Name;
//lc.setOpportunityName(oppName);
lc.setAccountId(acctID);
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
System.assert(lcr.isSuccess());
//leadConverts.add(lc);
}
}
//if (!leadConverts.isEmpty()) {
//List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
Not sure if I should make these fields not required on the Salesforce side to prevent error or deactivate the trigger. Also discovered that a blank application can be submitted which should not be the case. Please advise how to remove the error message and if it should be addressed on the application side on the website or the Salesforce side.
Greetings!
Seems like the required fields are missing while creating the Account and Contact records.So,I would suggest you to try by mapping the fields to account and Contact records to avoid getting error.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Please mark this as best answer if this answered your question.
Used this Trigger for Lead Convert and set the according to condition
Logging into the TP-Link router is immensely important. After installing the router, you’ll have to configure the settings. To access the router’s admin panel, you’ll require the http://tplinkwifi.net (https://tplinkswifi.net/) address. You can use the IP address of the router as well. However, if you don’t know the IP address of the router, you can try logging in with this.
The default web address wifi.wavlink.com allows you to login to your device and configure its settings. To login to the Wavlink device, enter the defualt web address in the web browser. Press Enter and you will reach the login page. Enter the login credentials and you will be logged into the device.