Find your content:

Search form

You are here

Is there any way to invoke contact triggers on a person account?

 
Share

Background: I have an org that uses person accounts and an appexchange package that does not support them. However when looking into why they're unsupported the only thing that does not work is that triggers designed for contacts are not firing on person accounts (expected, they fire account triggers instead).

However as the contact trigger is managed I can't just copy it over and apply it to accounts to get this working. I am free to write any apex needed in my own org, so I could for example write a brand new apex trigger on account that manually performed DML on the contact sObject. However I tried this and saw account triggers only running despite the explicit update op on a contact.

With all that said, is there any way to get salesforce to run contact triggers on my person account?


Attribution to: ca_peterson

Possible Suggestion/Solution #1

I don't use Person Accounts however if Workflows still fire appropriately when Contacts are updated then you could use an e-mail action to a Salesforce e-mail endpoint to fire an e-mail service.

http://wiki.developerforce.com/page/An_Introduction_To_Email_Services_on_Force.com

Here is a blog article that goes into the specifics of a process that fires a workflow, generates an e-mail to an endpoint which then runs a particular class.

http://iwritecrappycode.wordpress.com/2011/01/31/invoke-apex-class-via-workflow-rule/


Attribution to: Joseph U.

Possible Suggestion/Solution #2

Set up your trigger on the account object. When it fires in the instance of a Person Account all fields typically on the contact will be available on the account object, e.g. a.Lastname, (custom fields will end with __pc).


Attribution to: David Gillen

Possible Suggestion/Solution #3

If there's a way to do it, I haven't found it.

However, though it doesn't help your immediate need, it's not hard for managed package vendors to add account triggers, identify the person accounts, query for the backing contacts and run the same code they would run if it were a contact trigger - that is, assuming they've designed their software correctly.

So, it may be time to contact the package vendor and see if they can help you out.


Attribution to: kibitzer

Possible Suggestion/Solution #4

OK, I want to preface this with the statement that this is probably a horrible solution. A truly dark, abominable solution. Working with Salesforce I've had to become somewhat accustomed to creating monstrous code. Do not read further if you are faint of heart or short of courage.

You could create an evil twin contact record. It would have all the same data as the Person account but it's a contact. You write a trigger on the account so when a person account is updated, it also updates it's evil twin the contact record. This will fire the contact trigger.

Now, I don't know what that contact trigger is doing that you need - is it modifying the contact record? If so then we have more gruesome work ahead of us. Now, we need to take the modifications to the contact and use another trigger to update the person account. We'll have to be careful to not cause a recursive loop of unholy updates between person account and contact.

If the trigger was affecting other records (non contact) we are possibly fine.

I'm sorry if this answer has made you sick to your stomach - imagine how I must feel having written it. A swirling maelstrom of denormalized shadow data... It's an interesting approach - certainly not a good approach... but it just might actually work.


Attribution to: Ryan Elkins

Possible Suggestion/Solution #5

I do not think you can invoke managed package's Contact triggers on Person Accounts. This really should be a re-work on the managed package to make it "Person Account compatible". If you have the control on the managed package, you could refactor the code to allow the same logic of Contact triggers to be invoked on Person Accounts. See my blog post: http://force746.wordpress.com/2014/02/19/invoke-contact-triggers-logic-on-person-accounts/


Attribution to: user6941
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1209

My Block Status

My Block Content