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
Kimberly Wargo 1Kimberly Wargo 1 

Need help with some Apex Test Trigger that is failing

Good Morning,
I am not knowledgable on Triggers. I have a test trigger that is failing in my org that seems to be locking up records on my bulk import. Can anyone clue me in on where to start looking to see why now it is failing?
Thanks
Kim
User-added image
Kimberly Wargo 1Kimberly Wargo 1
Here is my error:
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Household may not use Household field : Investment Associate: [Investment Associate] 
Stack Trace: Class.testSetHHPendingFISClient.testThis: line 6, column 1
Alain CabonAlain Cabon
Hi,

There is another class testSetHHPendingFISClient and there is an error for inserting a Household with the field "Investment Associate" (missing or problem of security for this field, not visible)

Regards
venkat-Dvenkat-D
The error seems to be coming from your test class. Check for any validation rules that restricts sepcific data to fields Investment associate based on household type. 
Kimberly Wargo 1Kimberly Wargo 1
There are no validation rules. That was the first thing I checked. In both the account and contact object
venkat-Dvenkat-D
Then check for any dependency picklists. Can you post your test class? 
Alain CabonAlain Cabon
You didn't post the test class but the trigger. The error message is related with the field [Investment Associate] in object Household.

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Household may not use Household field : Investment Associate: [Investment Associate
Stack Trace:
Class: testSetHHPendingFISClient
MethodtestThis: line 6, column 1

Regards
Kimberly Wargo 1Kimberly Wargo 1
User-added image
Here is my test class
Alain CabonAlain Cabon
This is the trigger.

setup > 'classes' (quick search) Apex Classes : letter 'T' and you will find: testSetHHPendingFISClient but that could be a class from an installed package perhaps so you cannot see the source code (but the name only).

Regards
Kimberly Wargo 1Kimberly Wargo 1
But why is it failing??
Grrrr

User-added image
Alain CabonAlain Cabon
Hi,

It is not an easy problem indeed. We have to look at all the triggers and flows on Account now (bad news).
Your test class never creates directly an Household with the field : Investment Associate: [Investment Associate].
So this creation of Household is done by an other trigger on Account or a process/flow (perhaps unwanted and should be unactivated).

setup > Account (quick search) > Triggers : there should be other triggers (copy/paste their code)(very common).

setup > Process builder : look at your processes (less common than triggers but quite easy to understand)

setup > Flows : look at your flows (rare and more complicated than the previous processes)

We can unactivate this unwanted trigger/process/flow as soon as we have found it.

Regards
Kimberly Wargo 1Kimberly Wargo 1
Good Morning Alaln...
I did some digging and this is a pretty big nut to crack. When our initial implenetation was done, the firm that did it installed several "hidden" packages that seem to tie in to many other objects. I need to work in my sandbox and unravel them all. I tried some this morning doing a few and it's pretty massive. They set us up with people accounts and I think when I do the unravel I would like to move that back over to Business accounts at the same time. In the interim I will muddle through until I have the time to devote to this without affecting my day to day operation.

Thank you sincerely for your help.
Kim