3

Good afternoon!

Looking for broad idea collection around the concept of triggering an Outbound Message upon an upload of an Attachment -with either a specific filename or a certain naming syntax- to a Custom Object.

I have perused the details at "Is it possible to trigger a workflow outbound message when a custom related list item is added or removed?" but for my use case, the Attachment object is the standard Notes & Attachments functionality within SF, not a custom object connected via joint object.

I figure this is a trigger, but more defined questions would be forthcoming once I get a general idea of feasibility here.

Thanks to all!

3
  • 1
    This community is great for specific questions on specific problems. Open forums for discussion and ideas don't usually find their place here.
    – dphil
    Commented Jul 1, 2015 at 20:33
  • I'm going to flag this for re-opening. There are many questions posted that amount to "find the cause of the NPE for me" or "how do I write a test" that add little to this knowledge base. This question - "how can I fire an Outbound Message when I attach something" - seems to me a much more valuable piece of knowledge that if I needed to do I would be delighted to find a ready-proven solution for.
    – Keith C
    Commented Jul 2, 2015 at 8:25
  • 1
    Thank you both for your responses. I'll be happy to use the forum in the future as I'm relatively new to StackExchange and didn't consider the forums previously. As for my Question, I hope I didn't mis-represent that I was looking for 2-3 possibilities as to my "specific" use case, not possibilities in general. Have a great one! Commented Jul 2, 2015 at 13:27

1 Answer 1

2

I've never tried this so there may well be gotchas. It assumes you want to stick to the platform's Outbound Message mechanism (rather than make a HTTP request in your own code), that it is only specific custom object(s) that you want the messages for, and that you don't mind adding a field to the custom object(s).

Add a DateTime field to the custom object called something like AttachmentLastAdded, then create a workflow rule that checks if that field ISCHANGED and sends the Outbound Message that you want.

Also add a trigger to Attachment (this has to be through e.g. the Force.com IDE) that modifies the AttachmentLastAdded field and so causes the workflow rule to run:

trigger AttachmentInsert on Attachment (after insert) {
    Map<Id, YourCustomObject__c> m = new Map<Id, YourCustomObject__c>();
    for (Attachment a : Trigger.new) {
        if (a.ParentId.getSObjectType() == YourCustomObject__c.SObjectType) {
            // Your naming tests
            if (a.Name ...) {
                m.put(a.ParentId, new YourCustomObject__c(
                        Id = a.ParentId,
                        AttachmentLastAdded__c = DateTime.now()
                        ));
            }
        }
    }
    update m.values();
}
2
  • Thanks for your insight Keith C! I'll reply in depth as soon as I'm out of a meeting! Commented Jul 2, 2015 at 13:26
  • What a weekend, followed by one of those Mondays! I intend to sandbox test your suggestion today Keith, thank you. I'll let you know how it turns out. Commented Jul 7, 2015 at 12:48

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