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
khushbukhushbu 

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

PremanathPremanath

Not possible

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

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....  

khushbukhushbu

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','http://www.w3.org/2001/XMLSchema','double','1','1','false'};
        private String[] packageVersions_type_info = new String[]{'packageVersions','http://soap.sforce.com/2006/04/metadata','PackageVersion','0','-1','false'};
        private String[] status_type_info = new String[]{'status','http://soap.sforce.com/2006/04/metadata','ApexCodeUnitStatus','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/2006/04/metadata','true','false'};
        private String[] field_order_type_info = new String[]{'apiVersion','packageVersions','status'};
    }

 

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

What you think?

It will work?

I am having no idea for this API too..

PremanathPremanath

oh i haven't worked on webservices..

 

This link might be helpful for you

 

http://salesforce.stackexchange.com/questions/9603/how-do-i-use-the-tooling-api-to-create-a-new-apex-trigger

 

 

Thanks

Yoganand GadekarYoganand Gadekar

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

khushbukhushbu

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.

http://www.salesforce.com/us/developer/docs/api_tooling/index_Left.htm#StartTopic=Content/sforce_api_objects_apextriggermember.htm