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
Brandon (Penrod)Brandon (Penrod) 

Contact Accounts (Auto-Set)

Our code sets the account of contacts that are created without an account (to a set account). It works in test and the apex test in our staging works well also, but the end result is not the same in our staging environment. We tried to debug the code and it seems like something is setting the account back to the contact account after we update it to the account we want. The test and staging are both sandboxes and have the same packages installed.

I was wondering if there is a setting in Salesforce that may have been set in our test environment that I can change in staging to make the results the same?
Sonam_SFDCSonam_SFDC
Hi,

Is there a chance there is a trigger on Contact which is setting the Contact Acocunt to the previous value? Can you please do the following:
1)Set debug logs on your Username on the staging environment
2)Reproduce the issue on the platform and check the logs
3)Chekc to see if there is any process other than your code set which might be working on the contact update to reset the account field value 
Brandon (Penrod)Brandon (Penrod)
Hello,

We checked the logs and there were extra processes running but couldn't tell why they were running in the staging environment but not in the testing environment. The extra processes were all from the installed packages that both environments have and have activated.

We also couldn't tell if those processes were responsible for the account being reset.

Thank you,
Brandon
Brandon (Penrod)Brandon (Penrod)
I solved our issue by modifying our code until it worked. But it is still a mystery why the code that worked in one environment wouldn't work in another given the circumstances we had.