function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sree SalesforceSree Salesforce 

trigger error

apex trigger contactscreation caused an unexpected exception, contact your administrator: contactscreation: execution of AfterInsert caused by: System.DmlException: Insert failed. error: FIELD_CUSTOM_VALIDATION_EXCEPTION, only dollar and gup allow: [currency__c]: line 22, column 1

trigger contactscreation on Account (after insert) {
 map<id,decimal> m1=new map<id,decimal>();
 list<contact> l1=new list<contact>();
 
  for(account acc:trigger.new)
  {
  m1.put(acc.id,acc.Number_of_loc__c);
 }
 if(m1.size()>0 && m1!=null)
 {
  for(id accid:m1.keyset())
  {
  for(integer i=0;i<m1.get(accid);i++)
  {
   contact c1=new contact();
   c1.accountid=accid;
   c1.lastname='contact'+i;
   l1.add(c1);
   }
   }
     if(l1.size()>0&&l1!=null)
insert l1;
   }
 
   }
Best Answer chosen by Sree Salesforce
Tushar sharmaTushar sharma
In your contact object one required field currency is used you are not filling data in this so your custom validaton rule causing this exception please check this or disable your validation rule.