I'm not having any luck googling this and my google-fu is typically "Awesome." Do note we're talking about Partner object, not OpportunityPartner.
I'm using system.RunAs() to simulate a normal sales user profile. I'm creating two accounts, acc1 and acc2, one contact on acc1, and one Opportunity on acc1.
If I try to create a new partner record such as:
Partner thisPartner = new Partner(); thisPartner.Role = 'Test Role'; thisPartner.IsPrimary = true; thisPartner.OpportunityId = opp; thisPartner.AccountToId = acct2; insert thisPartner;
I get the following error:
System.SObjectException: Invalid field Role
On the above line
thisPartner.Role = 'Test Role';
If I comment system.RunAs(); it inserts just fine as a SysAdmin user.
If I just hit "New Partner" on the webpage Opportunity detail related list as an actual user with the same profile as the test user, it works fine.
What might I be missing? Thank you.