function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ayush Jain 116Ayush Jain 116 

Apex Trigger on contact object created from flow

I am unable to trigger an Apex trigger on contact object (getting created from a flow ) with 'after insert' condition. My trigger doesn't recognise the contact created from the flow and it doesn't work. 
I have tested the trigger by manually creating a contact and it was working well. 

here is the flow for the 

flow create a person account and then it creates a contact
My goal is to fetch the Contact ID into a trigger. Please suggest some solutions.

Best Answer chosen by Ayush Jain 116
Ayush Jain 116Ayush Jain 116

Hi, 
Thanks a lot for your time I found this blog and it is mentioned here that "Inserts, updates, and deletes on person accounts fire Account triggers, not Contact triggers."

So, I think if I create an account trigger with a field to carry the contact id. i might be able to do the triggering. 
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_ignoring_operations.htm

I really appreciate your helping nature. 

Thanks,

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Ayush,

Is the flow working as expected and creating the Contact succesfully. Usually it should trigger the Contact Trigger.

Thanks,
 
Ayush Jain 116Ayush Jain 116

Thanks for responding Praveen,

I have checked multiple times and the flow is working fine.

For this flow i need to create a lead with specific ownerId and then it creates an account then contact and then delete the lead. I have checked in the CRM and i am able to find the newly created contact but the trigger doesn't work for it ( i have checked the logs ). 

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Ayush,

Can you confirm what type of flow you created so I can check the same in my org and check it.

Thanks,
Ayush Jain 116Ayush Jain 116

Hi Praveen,

I have created a Record-Triggered Flow, which is triggered when a lead with specific OwnerId is created. 

It checks for duplication and then creates a prospect account then contact and then deletes the lead...

I am able to verify that after creating a lead a contact is created. I don't understand why the trigger is not working for this scenario. 

Thanks,

Ayush Jain 116Ayush Jain 116

Hi Praveen, 

This is the new Flow i have created. I am creating a person account using flow and that person account in turn creates a contact. I want to place a trigger for that contact.
User-added image

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Is Contact Trigger working if you create a personal Account manually?

Thanks,
 
Ayush Jain 116Ayush Jain 116

No, when i created a person account manually, a contact is created automatically but the trigger didn't work on it. 

I guess the problem is with this person account.

Do you have a solution for that ?
 

Sai PraveenSai Praveen (Salesforce Developers) 
Hi ,

Can you share the trigger so I can check it.

Thanks,
 
Ayush Jain 116Ayush Jain 116

Hi, 
Thanks a lot for your time I found this blog and it is mentioned here that "Inserts, updates, and deletes on person accounts fire Account triggers, not Contact triggers."

So, I think if I create an account trigger with a field to carry the contact id. i might be able to do the triggering. 
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_ignoring_operations.htm

I really appreciate your helping nature. 

Thanks,

This was selected as the best answer