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

Create Trigger dynamically

Hello , 


 I want to create trigger dynamically.

Basically my requirement is :


  I am creating custome objects dynamically throgh metadata services.

 Now whenever my new CO done, my trigger should also be created dynamically.


Please help me out


Not possible

Leave other things. Please tell me ...can i create trigger dynamically?  

We are writing the triggers for Auto mate the process.


You want any dynamic functionality in your org then you can go with the trigger.


How can you create Triggers Dynamically.....


We need to create triggers Manually....  


Ya ..Thats true.

But I am dynamically creating my custom object.

Is there any API for this ?


For creating custom objects , I have used metadata service API.


Any other API for creating same thing with trigger?



They have given this code for this in metadataService :


  public class ApexTrigger {
        public Double apiVersion;
        public MetadataService.PackageVersion[] packageVersions;
        public String status;
        private String[] apiVersion_type_info = new String[]{'apiVersion','','double','1','1','false'};
        private String[] packageVersions_type_info = new String[]{'packageVersions','','PackageVersion','0','-1','false'};
        private String[] status_type_info = new String[]{'status','','ApexCodeUnitStatus','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'','true','false'};
        private String[] field_order_type_info = new String[]{'apiVersion','packageVersions','status'};


But they have not provided any to use it...

What you think?

It will work?

I am having no idea for this API too..


oh i haven't worked on webservices..


This link might be helpful for you




Yoganand GadekarYoganand Gadekar

Interesting... do update here if you happen to achieve this.


Ya Sure..

Chris Berg 6Chris Berg 6
Appearently the Tooling API provides the services you need to create forms, Apex class, triggers etc programitically.  I have found several posts on the Internet stating it's not possible and it is confusing people.