0

I have created a lightning component, using this I create business account or person account conditionally. The standard New button of Account has been overridden by this custom lightning component. I can create the business account without any issue. But while creating the person account, we are getting error occasionally.

Note: 1. If the person account is created in standard way, it is not throwing any error. 2. If I remove the override of New button and create a person account in standard way, and then we again override it with lightning component and go for creating the person account, it is not throwing any error. After few hours, it is throwing error again.

The error is: Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

Below is the code snippet which creates Account creation pop up:

if(!(checkRecordType==null) && !(checkRecordType==''))
    {
            if(checkRecordType=='Business Account'){
                var createAcountEvent = $A.get("e.force:createRecord");
                createAcountEvent.setParams({
                    "entityApiName": "Account",
                    "defaultFieldValues": {
                        "Name" : accName,
                        "RecordTypeId" : component.get("v.businessAccRecTypeId")
                    }
                });

                $A.enqueueAction(component.get('c.closeModal'));   
                createAcountEvent.fire(); 
            }else if(checkRecordType=='Person Account'){

                var evt = $A.get("e.force:createRecord");
                evt.setParams({
                    "entityApiName": "Account",
                    "defaultFieldValues": {
                        "RecordTypeId" : component.get("v.personAccRecTypeId")
                    }
                });
                $A.enqueueAction(component.get('c.closeModal')); 
                evt.fire(); 

            }
    }else if((checkRecordType==null) || (checkRecordType==''))
    {
        alert("Please select a record type");
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.