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
sai krishna 267sai krishna 267 

hi friends give me code to restrict the code for per we can able to create 15 Accounts morethan that it will be showing an error u daily limit exceeded can anybody give code

Suraj TripathiSuraj Tripathi
Hi Sai,

Try this trigger

Trigger-
trigger test on Account (before insert) {

    if(trigger.isBefore&& trigger.isInsert){
        daily15limit.m2test(trigger.new);
    }
}

Handler Class-
public with sharing class daily15limit {
    public static void m2test(list<Account> Acclist){
        
        List<Account> accOld = [select id from Account where CreatedDate = TODAY];
        system.debug('accOld--------->>>>'+accOld);
        system.debug('accOld.size()----------'+accOld.size());
        
        for(Account acc : Acclist) {
            if(accOld.size()>15)
            {
                acc.addError('Daily Limit Exceeded');
            }
        }
        
    }
    
}

If it helps you mark this best.

Regards
Suraj​