• KalyanG
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
While doing a custom conversion, my Users are facing this error messages "ConvertLead failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type". The default record type for their profile is different than the recpord type needed for the conversion. I added a Permission Set to add the Assigned Record Type (there is no way I can add a default record type through a Permission Set).
The Lead conversion process has an existing Account (so no new Account to create) and also an existing Contact to map.
What can be done to let the Users Convert this Lead through the custom process?
Hi All - I was so excited I was able to create this very "simple" trigger (so new to this) and when I went to deploy it to Prod I received a 0% Code Coverage error. Could someone please help me understand this code coverage madness and what I actually need to do? Is it an Apex Class? I'm so lost...any help is much appreciated, my trigger below for reference.

trigger AttachmentCount on Attachment (after insert)
{

List<lead> co = [select id, Attachment_Added__c from lead where id =:
Trigger.New[0].ParentId];
if(co.size()>0)
{
co[0].Attachment_Added__c = True;
update co;
}
}
Challenge - Create a form to enter new items and display the list of items entered. To make our camping list look more appealing, change the campingHeader component to use the SLDS. Similar to the unit, style the Camping List H1 inside the slds-page-header. Modify the campingList component to contain an input form and an iteration of campingListItem components for displaying the items entered.
The component requires an attribute named items with the type of an array of camping item custom objects.
The component requires an attribute named newItem of type Camping_Item__c with default quantity and price values of 0.
The component displays the Name, Quantity, Price, and Packed form fields with the appropriate input component types and values from the newItem attribute.
The JavaScript controller checks to ensure that the Name, Quantity and Price values submitted are not null.
If the form is valid, the JavaScript controller pushes the newItem onto the array of existing items, triggers the notification that the items value provider has changed, and resets the newItem value provider with a blank sObjectType of Camping_Item__c.


My answer - 
<aura:component >
<aura:attribute name="items" type="Camping_Item__c[]"/>
<aura:attribute name="newitem" type="Camping_Item__c[]"  default="{ 'sobjectType': 'Camping_Item__c',
                   'Quantity__c'=0, 'Price__c'=0}"/>
 <p>Name:
        <ui:inputText value="{!v.newitem.name}"/>
    </p>    
  <p>Packed:
        <ui:inputCheckbox value="{!v.newitem.Packed__c}"/>
     
    </p>    
  <p>Price:
        <ui:inputCurrency value="{!v.newitem.Price__c}"/>
    </p>
    <p>Quantity:
        <ui:inputNumber value="{!v.newitem.Quantity__c}"/>
    </p>
</aura:component>


Error -

Challenge Not yet complete... here's what's wrong: 
The campingList component isn't iterating the array of 'items' and creating 'campingListItem' components.

Please share the correct solution.
Hi All,

I have a custom object named Payment, which has look up to Lead. On Payment page, I have a button to call Apex class, which changes Lead status which in turn results in after update lead trigger that converts lead using  Database.convertLead() method.
I am having System Administrator profile, but I am getting error as ConvertLead failed. First exception on row 0; first error: UNAVAILABLE RECORDTYPE EXCEPTION, Unable to find default record type

Note: I just created new sandbox, and this function has stopped working on new sandbox. Same functionality is working on Production. My profile has default record type assigned for Account, which is common answer found for this issue. But that is already in place and issue still persists. Convert Lead option is also enabled for me.

Lead, Opportunity do not have record types and there is no custom field vaidation exception shown in debug log.

Any help is highly appreciated.

Approval Page Error on Payment details page:
User-added image
 
//Code for class called from Payment detail page button: 

global class nmLeadWebService 
{
    //New method for Approve registration by IC
    webService static string ApproveRegistrationNew(String strLeadId) 
    {
         Lead objLead = new Lead(id=strLeadId);
         objLead.nm_LeadContacted__c = 'Yes'; 
         
         update objLead;
        
         objLead.nm_PaymentCompleted__c = true;
         
         update objLead;
       
         objLead = [select id, ConvertedAccountId, convertedOpportunityId from Lead where id =: strLeadId];
        
         //Code to transfer registration payment record to opportunity from lead
         List<nm_Payment__c> lstPayment = [select id, nm_OpportunityNew__c from nm_Payment__c where nm_Lead__c =: strLeadId and nm_PaymentStatus__c='Payment Made'];
         if(lstPayment != null && lstPayment.size() > 0)
         {
            for(nm_Payment__c objPayment : lstPayment)
            {
                       
                objPayment.nm_Lead__c = null;
                objPayment.nm_OpportunityNew__c = objLead.ConvertedOpportunityId;               
            }
            
            update lstPayment;
         }
         system.debug('Done');
         return objLead.ConvertedAccountId;
    }

//Code in Lead Trigger handler class
//Method to convert lead once Registration payments completed
    public void ConvertLead(list<Lead> lstLead, map<id, Lead> leadOldMap)
    {
        if(lstLead != null && lstLead.size() > 0)
        {
            set<string> strDuplicate = new set<string>();
            //Adding Email MobilePhone in set in string format 
            for(Lead objLead : lstLead)
            {
                strDuplicate.add(((String)objLead.Email + (String) objLead.MobilePhone ).toLowerCase());
                System.debug('**strDuplicate'+strDuplicate);
            }
            
            //getting accounts already in Account
            list<Account> lstAccount = [select id,(select id from Contacts limit 1), 
                                        nm_CheckDuplicate__c from Account
                                         where nm_CheckDuplicate__c in : strDuplicate];
            System.debug('**lst account'+lstAccount);
            map<string, Account> mapDupAccounts = new map<string, Account>();
            for(Account objAccount : lstAccount)
            {
                mapDupAccounts.put(objAccount.nm_CheckDuplicate__c, objAccount);
            }
            LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            for(Lead objLead : lstLead)
            {
                //Checking is registration payment done
                if(objLead.nm_Program__c != null && objLead.nm_EligiblityCriteria__c != null && objLead.nm_PaymentCompleted__c == true && leadOldMap.get(objLead.id).nm_PaymentCompleted__c == false)
                {
                    string strLead = ((String)objLead.Email + (String) objLead.MobilePhone ).toLowerCase();
                    if(mapDupAccounts.get(strLead) != null)
                    {
                        Database.LeadConvert lc = new Database.LeadConvert();
                        
                        lc.setLeadId(objLead.id);
                        lc.setAccountId(mapDupAccounts.get(strLead).id);
                        
                        lc.setContactId(mapDupAccounts.get(strLead).Contacts[0].id);
                        
                        
                        lc.setConvertedStatus(convertStatus.MasterLabel);
                        
                        try{
                            Database.LeadConvertResult lcr = Database.convertLead(lc);
                        }
                        catch(exception ex)
                        {
                            objLead.addError(ex.getMessage()); 
                        }
                    }
                    
                    else
                    {
                        Database.LeadConvert lc = new Database.LeadConvert();
                        
                        lc.setLeadId(objLead.id);
                        
                       // LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
                        lc.setConvertedStatus(convertStatus.MasterLabel);
                        
                        try{
                            Database.LeadConvertResult lcr = Database.convertLead(lc);
                        }
                        catch(exception ex)
                        {
                            objLead.addError(ex.getMessage());
                        }
                    }                   
                }
            }
        }
    }

 

Hi All,

 

Now,am working on web-to-lead using custom controller.I have written a workflow to send a email alert.When I give the inputs for required fields and submit it. Lead info is not stored in Lead object and in debug log , i have seen the following exception,

System.DmlException: Insert failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type

 

I have set the default record type for Lead.But Lead is not stored.

 

Whenever I deactivated the workflow, it works fine and there is no exception arises .Please guide me to clear this one.

 

Thanks in advance.

Hai All,

 

When i am converting a lead Its giving Error

Error: ConvertLead Failed: First exception on row 0; First error: UNAVAILABLE_RECORDTYPE_EXCEPTION,unable to find defaultnrecord type[]

 

Below is the Class code On convert lead

// This class is meant to hold all the code which will be reusable and common processes. Some webservice methods we can write here also.

global class Lead_Manager
{
    // Responsible for lead conversion from standard page layout.
    // Below webservice method is being called on the click event of the custom convert button on the standard lead page layout.
    WebService static String convertLeadByConvertCustomeButton(String leadId)
    {
        try
        {
            Lead led = [Select id,Name,Status,LeadSource ,IsConverted ,(Select id,ContentType,Name,LastModifiedDate from Attachments) from Lead where id = :leadId];
            if(led.Attachments.size()==0)
                return 'Please upload documents before converting the lead.';
            if(led.Status=='Approved')
            {

             // Here it is throwing Error
                Database.LeadConvert lc = new database.LeadConvert();
                lc.setLeadId(leadId);
                LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
                lc.setConvertedStatus(convertStatus.MasterLabel);
                lc.setDoNotCreateOpportunity(true);
                Database.LeadConvertResult lcr = Database.convertLead(lc);
                //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.confirm,'Lead has been converted successfully.'));
                led = [Select id,Name,Status,LeadSource ,IsConverted ,ConvertedAccountId,ConvertedContactId from Lead where id = :leadId];
                /* List<Contact> contactList = [Select id from Contact where id=:led.ConvertedContactId];  
                if(contactList.size()>0)
                    delete contactList; */
                return String.ValueOf(led.ConvertedAccountId);
            }
            else
                return 'CSR has not approved the lead so it can not be converted.';
            
        }
        catch(System.Exception e)
        {
            return e.getMessage();
        }
    }
 
    //Lead conversion custom method. This method will take an instance of Lead object
    //and will convert it without creating opportunities and returned the converted lead to its caller.
    // Responsible for lead conversion from visual force.
    public static Lead convertLead(Lead lead)
    {
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(lead.Id);
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        lc.setDoNotCreateOpportunity(true);
        
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        Lead led = [Select id,Status,LeadSource ,ConvertedAccountId,RecordType.Name,Name,OwnerId,CreatedById,FirstName,LastName,Street,City,State,PostalCode,Email,phone,Last_4_digits_SSN__c,Date_of_Birth__c,IsConverted,
                            Enrollment_Id__c,EBT_Number__c,EBT_Holder__c,Number_of_Persons_or_Household__c,Monthly_Income__c,Yearly_Income__c
                            from Lead
                            where id = :lead.id];
       return led;
    }
 
 
    @RemoteAction
    global static String checkLeadApprovalStatusByCSR(String leadId)
    {
        Lead lead = [Select id,Status from Lead where id = :leadId];
        if(lead.Status == 'Approved')
            return '1';
        else
            return '0';
    }
 
}