You need to sign in to do that
Don't have an account?
karimulla salesforce
hi, iam going to insert a multiple records using a forloop on the account object, but getting an dml exception.
//if tried for contact object , it is getting work , may i know the reason behind it...
Thanks
karimulla syed
Dml Exception while inserting multiple records using a for loop
for(integer i=1; i<=10; i++){ Account a = new account(); a.name ='sha'; a.phone='123'; a.annualrevenue=9096; insert a; }
hi, iam going to insert a multiple records using a forloop on the account object, but getting an dml exception.
//if tried for contact object , it is getting work , may i know the reason behind it...
Thanks
karimulla syed
I guess the error is due to duplicate rules enforced in your org. Try navigating to Setup-> Duplicate Rules-> Check if there is any rule on Account.
As there is no such rule which is meeting the criteria on contact duplicate rules your records are inserted on contact object.
More on duplicate rules:
https://help.salesforce.com/articleView?id=duplicate_rules_map_of_reference.htm&type=5 (https://help.salesforce.com/articleView?id=duplicate_rules_map_of_reference.htm&type=5)
Hope this helps ! Please mark as best if it does.
Thanks
You are facing this issue because of the Rules defined in salesforce for managing Duplicate Accounts .
A matching rule defines how duplicate records are identified in duplicate rules and duplicate jobs. Salesforce provides standard matching rules for business and person accounts, contacts, and leads. You can also create custom matching rules.
Refer Standard Account Matching Rule (https://help.salesforce.com/articleView?id=matching_rules_standard_account_rule.htm&type=5) .
Since in your case you are using the same Account name for all the Accounts you are creating inside the loop , you are getting this Error .
Try changing the name , For example
Also , I would suggest that never Insert inside a for loop . you may run into limits soon .
I have gone through your problem.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora