Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

I am attempting to deactivate triggers using the tooling API. I have successfully in a developer ORG. But was unable to do this in a real developer org. Is this a Salesforce tooling api bug?

Here is the basis of the algorithm,

  1. Create a MetadataContainer with a unique Name
  2. save MetadataContainer
  3. Create an ApexTriggerMember setting the Body, MetadataContainerId, ContentEntityId, and Metadata[apiVersion=33.0 packageVersions=[] status="Inactive" urls=nil>]
  4. Modify Metadata["status"]="Inactive"
  5. save ApexTriggerMember
  6. Create/Save ContainerAsyncRequest
  7. monitor container until completed.
  8. display errors if appropriate

In the sandbox, I have confirmed after requerying the Apex enter code hereTriggerMember that the read-only field "Content" looks appropriate. I also confirmed that the MetadataContainerId now points to a ContainerAsyncRequest that has a State of "Completed"

Here are my results, it appears to be a success, but the ApexTrigger is never deactivated ContentEntityId = 01q.............[The ApexTrigger I want deactivated]

Content="<?xml version=\"1.0\" encoding=\"UTF-8\"?>

    <ApexTrigger xmlns=\"urn:metadata.tooling.soap.sforce.com\">

        <apiVersion>33.0</apiVersion>

        <status>Inactive</status>

    </ApexTrigger>" 

Metadata={apiVersion=33.0 packageVersions=nil status="Inactive" urls=nil> attributes=        {type="ApexTriggerMember"

     url="/services/data/v33.0/tooling/sobjects/ ApexTriggerMember/401L0000000DCI8IAO"

  }

}

1 Answer

0 votes
by (32.1k points)
edited by

You can follow these steps to deactivate the trigger :

1) Impair the trigger on the sandbox environment

2) Build a new project in Eclipse utilizing the Sandbox and introducing the trigger 

3) Alternative: edit the triggername.trigger-meta.xml in an existing project and change the status node to false: <status>Inactive</status>

4) Save the change locally

5) Deploy the trigger to production

6) Complete the data load

7) If the change is not permanent or you want to enable the trigger again then enable the trigger by making it active on the sandbox or project again and deploy it to production

To learn in-depth about Salesforce, sign up for an industry-based Salesforce Certification!

Browse Categories

...