5

I wanted to use Process Builder + a flow to automatically delete the chatter post generated on an account when a lead is converted. I've created both parts, but it doesn't seem to be working...

Here's the process builder:

Process Builder Overview Screenshot

It triggers on the "Feed Item" object, when an object is created or edited, with no recursion.

The action group criteria is pretty basic for now, just to test it -- with the only condition being FeedItem Type = "Tracked Change"

Process Builder Criteria Screenshot

And the only action is to launch the flow that deletes the record...

Process Builder Action Screenshot

The flow is just one part:

Flow Item Screenshot

Taking the variable ID from the Process Builder and deleting it

Flow Variable Screenshot

Any ideas why this wouldn't work?

4
  • Is there any any exception that is getting logged in debugs? Jul 10, 2016 at 2:26
  • @IshwarMete nothing that I see. I don't see any workflow processes at all in the debug log for the leadconvert and I don't receive any errors via email from process builder either
    – Matt
    Jul 10, 2016 at 2:45
  • There is an unmanaged package available with custom lead conversion vf page. Install that package and override the out of box lead conversion page with custom vf page and you can invoke whatever you want from controller on successful lead conversion. We used a similar approach to hide the checkbox 'Do not create opportunity' from standard lead convert page.
    – javanoob
    Jul 10, 2016 at 5:46
  • There is some sample trigger code on this idea to be able to turn this off: success.salesforce.com/ideaView?id=08730000000ZOlIAAW I would imagine an autolaunched flow that fires when lead is converted= true and queries the account and does the needful would work, but maybe not based on the comments below. Also can't hurt to try a wait element. Sometimes things work w a wait element that don't work immediately due to order of operations issues.
    – gorav
    Jul 10, 2016 at 19:25

1 Answer 1

3

The problem is that the Process Builder flow never even fires. Even if you remove the criteria and/or change the action, you will not see any activity. Check this document, which states:

Only FeedItems of type TextPost, LinkPost, HasLink, ContentPost, and HasContent can be inserted, and therefore invoke the before or after insert trigger. User status updates don't cause the FeedItem triggers to fire.

It seems like FeedItems created during Lead Conversion are not on the whitelist included in the above description (as you noted the Type is TrackedChange). I wrote an Apex Trigger on the FeedItem object after insert, and it indeed did not fire either. You're going to have to trigger on the Account object and find the FeedItems to delete another way. It seems like it should still be possible via Auto-launched Flow.


If triggering is impossible, you can use a pretty simple batch to find the records you want to delete.

public with sharing class DelteLeadConversionTrackedChange
    implements Database.Batchable<SObject>
{
    public Database.queryLocator start(Database.BatchableContext context)
    {
        return Database.getQueryLocator([
            SELECT Type FROM FeedItem
            WHERE Type = 'TrackedChange'
            AND Parent.Type = 'Account'
        ]);
    }
    public void execute(Database.BatchableContext context, List<SObject> scope)
    {
        List<Id> toDelete = new List<Id>();
        for (SObject record : scope)
        {
            String body = (String)record.get('Body');
            if (body.endsWith('converted a lead to this account.'))
                toDelete.add(record.Id);
        }
        Database.delete(toDelete)
    }
    public void finish(Database.BatchableContext context) { }
}
6
  • Any ideas on how to trigger via the Account? I tried triggering off the Lead -- when Converted AccountId changed, the PB would trigger, feed the AccountId into the flow that looked for any FeedItem with ParentId = AccountId and Type = TrackedChange, then delete them. Unfortunately, that didn't seem to work either.
    – Matt
    Jul 10, 2016 at 4:41
  • Might need Apex. Seems like it should be triggerable somewhere. The documentation on Operations That Don't Invoke Triggers is somewhat cryptic about the effects of conversion and only mentions before triggers... If all else fails you can run a batch process.
    – Adrian Larson
    Jul 10, 2016 at 5:10
  • It sounds like enabling Use Apex Lead Convert might cause workflows and triggers to run...worth a try.
    – Adrian Larson
    Jul 10, 2016 at 5:19
  • Unfortunately enabling that appears to cause a trigger to fail on conversion, so not sure that will be an option. I guess a roundabout way of achieving this would be to fire a PB on a completely unrelated Account or Contact edit, then use that to fire a flow that looks for all FeedItems matching the criteria? Ideally there'd be enough edits that each time it isn't deleting a huge chunk of FeedItems.
    – Matt
    Jul 10, 2016 at 5:47
  • @Matt You can use a pretty simple batch. Added an example.
    – Adrian Larson
    Jul 12, 2016 at 14:34

You must log in to answer this question.

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