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
suri03081988suri03081988 

Compail apex triggers

Hi,

i am trying to compail all triggers in my sandbox by using below code, but it is not throughing some erros

String[] listOfTrigger = new List<String>();
List<ApexTrigger> aTriggersList = [SELECT Id ,Name, NamespacePrefix from ApexTrigger];
System.debug('===> Count is: '+aTriggersList.size());
for(ApexTrigger at : aTriggersList){
    listOfTrigger.add(at.name);
    System.debug('===> Trigger name is: '+at.name);
}
CompileTriggerResult[] res = compileTriggers(listOfTrigger);  
System.debug('===> End <==='+res);


Please suggest me with proper code.
Thanks inadvance.
Deepali KulshresthaDeepali Kulshrestha
Hi,

Compile your Apex triggers in Developer Edition or sandbox organizations.
Syntax:- CompileTriggerResult[] = compileTriggers(string[] triggerList);
Use this call to compile the specified Apex triggers in your Developer Edition or sandbox organization. Production organizations must use compileAndTest().

for more information please go through the given links as it may help you in solving your problem.
:- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/sforce_api_calls_compiletriggers.htm
:- http://mysalesforcestuff.blogspot.com/2018/09/compile-all-triggers-feature-activation.html

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha