5

I wanted to explore using a SandboxPostCopy class upon sandbox creation but ideally need to disable triggers, validation and workflow rules first. Is there a way to do this programmatically via apex?

I feel like it should be possible, especially as the Salesforce Toolkit can but is it possible to with apex itself?

6
  • Tooling API maybe? I don't think callouts are supported though.
    – Adrian Larson
    Commented Sep 26, 2016 at 19:44
  • I am sure I have read on here there is a way of doing, maybe using github.com/afawcett/apex-toolingapi ?
    – Girbot
    Commented Sep 26, 2016 at 19:47
  • I mean I don't think the SandboxPostCopy context supports callouts.
    – Adrian Larson
    Commented Sep 26, 2016 at 19:48
  • 1
    ah. nuts. Time to have a "play" I guess!
    – Girbot
    Commented Sep 26, 2016 at 19:50
  • 2
    What if you had a Custom Setting that you could flag to disable all the triggers, validation rules, workflows, etc... ? Just set it as the first part of the sandboxpostcopy class. They would still be active, but wouldn't actually do anything. Commented Sep 26, 2016 at 20:50

2 Answers 2

3

Expanding on my prior comment.

You can use a Custom Setting that can be flagged to disable all the triggers, validation rules, workflows, etc...

Just set it as the first part of the SandboxPostCopy class. The triggers etc.. would still be active, but wouldn't actually do anything.


Summer `17 is introducing native Metadata access in Apex. It is currently limited to Custom Metadata Types and Layouts. Changing a triggers active state could be another good use case.

-1

You can try if Switch from Salesforce Toolkit could be helpful

Quickly and easily disable an Org's validation rules, workflows and Apex triggers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .