[SalesForce] Salesforce Validation Rule Only Create 1 Record a day

Any idea how to write a Validation Rule, that prevents the user from creating more than one record a day.

I have one Object called (Stundenkonto__c) it shows a Month in Timetracking.
I have a Object called (Zeiteintrag__c) it is the Master Detail of (Stundenkonto__c)
So the User should only be able to create only one (Zeiteintrag__c) Record a day.

Best Answer

You can do that with trigger. In your before insert trigger do something

trigger accTrigger on Zeiteintrag__c(before insert) {
   List<Zeiteintrag__c> zeiList = [SELECT Id FROM Account WHERE Zeiteintrag__c = TODAY]
  if(zeiList.size() > 0)
      trigger.new[0].addError('One record is already created');
}

With this small piece of code you can do this.

Related Topic