You need to sign in to do that
Don't have an account?
Varsha Pawar 4
Partner Account in test class
Hi Team,
In my Org, I have enabled Partner Account. On Account Trigger is has some logic, now I want to write a Test Class for this Trigger.
Can someone please help me how to make IsPartner = True/False in Test Class? Currently it gives error "FATAL_ERROR System.SObjectException: Field is not writeable: Account.IsPartner".
Thanks in Advance!
In my Org, I have enabled Partner Account. On Account Trigger is has some logic, now I want to write a Test Class for this Trigger.
Can someone please help me how to make IsPartner = True/False in Test Class? Currently it gives error "FATAL_ERROR System.SObjectException: Field is not writeable: Account.IsPartner".
Thanks in Advance!
Please see https://developer.salesforce.com/forums/ForumsMain?id=906F000000091RxIAI
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BJCb
that explains the same scenario and fix for the test class.
Thank you
As per https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_account.htm can you IsPartner Indicates whether the account has at least one contact enabled to use the organization's partner portal (true) or not (false).
Can you alter your test class code to match the below and let me know if it works?
You need to Create User by Passing in the contact ID
Account a = new Account();
insert a;
Contact c = New Contact(LastName = 'Test', AccountID = a.id);
insert c;
User newUser = createPartnerUser(c.id);
private static user createPartnerUser(ID cId){
Profile p = [Select ID, Name from Profile Where Name = 'YOUR PARTNER PROFILE NAME'];
user u = New User(
UserName = 'test_' + math.random() + '@test.com',
FirstName = 'Test-First',
LastName = 'Test-Last',
Alias = 'test',
email = 'test' + math.random() + '@test.com',
CommunityNickName = string.valueOf(math.random()).substring(0,6),
ProfileID = p.id,
TimeZoneSidKey = 'America/New_York',
LocaleSidKey = 'en_US',
EmailEncodingKey = 'UTF-8',
LanguageLocaleKey = 'en_US',
ContactID = cId
);
insert u;
return u;
}
a = [Select isPartner From Account where ID = :a.id];
system.assert(a.isPartner,'Is Partner flag was not set to true');
Incase you have further queries, please post your narrowed code snippet so that I can take a look.
Thanks