When I try to convert lead It says "Error: ConvertLead failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type: []"
Is there anything that I am missing?
[SalesForce] UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type: [] *Record Owner
Related Solutions
Salesforce platform has a feature ROW LEVEL Security. This feature ensures that sharing and visibility set by salesforce administrators for the records have to be maintained. As a part of this feature, there are sharing calculations that the platform has to perform when the record ownership is changed or child records are created/modified.
Assume that a company’s salespeople are adding new contacts into an account. When they click Save, the database automatically locks the parent account when it begins the DML operation and before it actually inserts the Contact. The database releases the lock after executing the triggers and standard save operations. This scenario illustrates the locking that can occur in parent-child relationships.
The next thing to understand is a side-effect known as parent implicit sharing. In a private sharing model, something else occurs when the Salesforce platform creates contact. The built-in implicit sharing feature provides record accessibility, and its parent implicit sharing provides read access to an account for users who have access to standard child objects, such as Contacts, Cases, and Opportunities.
So when salespeople create a Contact, sharing calculations determine during the save operation if a parent implicit share to the Account should be created. In this example, the calculations happen quickly. Assume that the salespeople have been very active and have created 300,000 child objects under a single generic account. They now have a skewed account.
If another salesperson tries to add a new contact for the same account while the sharing calculations are occurring, that request will wait for the Salesforce platform to release the lock on the account, resulting in lock contention and reduced database concurrency.
A record can also go into a Locked State if it is a parent and part of master-detail relationships and child records are getting saved/updated.
You can read how apex can prevent such locks using the link here
Using FOR UPDATE keyword in SOQL helps to achieve a lock on a client end to prevent these locking issues.
Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
Here are some helpful articles on how to design your sharing model to avoid granular locking
You can prevent using the below techniques
- Make sure you have an optimized data model with no Data Skews (No more than 10K child records for a parent record)
- Make sure you do not have Ownership skews(No single owner owning lots of records when the private sharing model is turned on).
- Ask support if they can enable granular locking
[SalesForce] AfterUpdate trigger operation fails; Record is currently being modified by another user
Since your trigger code isn't commented, it is unclear exactly what your intent is but I'll take a shot at correcting and commenting it.
trigger quotepotential on Quote_Line_Item__c (after insert, after update) {
// the IDs of quotes which we are going to populate the potential amount on
Set<Id> quoteIds = new Set<Id>();
// the list of Quote__c records which will be updated with the amount
List<Quote__c> quotesToUpdate = new List<Quote__c>();
// collect the ID value of the related Quote
for (Quote_Line_Item__c record: Trigger.new) {
if (record.Quote1__c != null) {
quoteIds.add(record.Quote1__c);
}
}
// use the quoteIDs set to get the aggregate sum per Quote1__c
for (AggregateResult ar : [SELECT Quote1__c
, SUM(Max_Batch__c)sumMax
FROM Quote_Line_Item__c
WHERE Quote1__c IN :quoteIds
GROUP BY Quote1__c]) {
// create an sObject to be used for the update operation
Quote__c qu = new Quote__c(Id = (Id)ar.get('Quote1__c'));
qu.Potential__c = (Decimal)ar.get('sumMax');
// add this sObject to the updates list
quotesToUpdate.add(qu);
/* Not sure why this code is here - it appears to not belong */
/* P.S. avoid DML operations in loops in all cases */
// list<quote__c> quo = [select id,potential__c from quote__c where id IN :quotes limit 1 for update];
// update quo;
}
// if there's work to be done, do it.
if (!quotesToUpdate.isEmpty()) {
update quotesToUpdate;
}
}
Best Answer
I think your problem is similar to this one https://developer.salesforce.com/forums/?id=906F000000093fPIAQ
so try this: go to Setup -> Manager Users -> Profiles, then select your profile type. From there, scroll all the way down to the Record Type Settings section and under the Standard Record Type Settings sub-section, Go to the Leads field and ensure that there are values there. If not, you'll need to click Edit and assign a default.