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
Natalie Jane HodsonNatalie Jane Hodson 

Apex Class to Relate New Contact to Current User's Account?

Hi,

A developer created a piece of apex code back in 2015 that is blocking a current deployment. For some reason it has only just started to fail, and without knowing the reason why, I (a non-developer) need to address the errors within the class.

The Apex class keeps updates of a portal user in sync with its corresponding contact. As far as I can see, as part of the Test, the code is creating a new portal user and contact record based on the Current Users details.

Unfortunately due to a flow triggered by contact creation, the class and subsequent trigger are not firing.The flow is looking for the account record of the contact that is being created, to update fields within the contact record. 

Is their a way to capture within the apex class the current user's related contact detail, to pull the account record to satisfy the flow? 
Shawn Reichner 29Shawn Reichner 29
There should be. On a portal users record, there is a lookup field called Contact.  That woudl be the link to the actual contact record for that portal user.  You could traverse through that lookup field and grabbing the Account ID or name and use this in your process if it is a portal user. 

Hope that helps! 

Shawn