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
mgodseymgodsey 

System.SObjectException: Invalid field AccountFromId

I have to create an account partner relationship in a unit test. I have written the below. However, it is failing at the bolded line, with the error: System.SObjectException: Invalid field AccountFromId. This is strange, right? The same logic is working in another class, and if I look up the partner object in the workbench 'AccountFromId' is clearly a valid field. Any ideas of what is going wrong? Thanks!

            Account acct = UnitTestFactory.makeAccount();
            Account agencyAcct = UnitTestFactory.makeAccount();
            agencyAcct.Type = 'Agency';
            update agencyAcct;

            Partner pa = new Partner();
            pa.AccountFromId = acct.Id;
            pa.AccountToId = agencyAcct.Id;
            insert pa;


Hargobind_SinghHargobind_Singh
By any chance, do you have a class named "Partner" as well ? if yes, then please rename it.