1

How do we query for non Guest users. with the new Guest Ownership Rules Test methods are failing: First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception (Guest users cannot be record owners.):

User notGuest = [Select Id
    From User 
    Where IsActive = true
    Limit 1];            
acc = new Account(
    Name = 'Test Account',
    OwnerId = NotU.id
);
Insert acc;
1

userType Field has these value options (not updateable):

  • Standard: user license. This user type also includes Salesforce Platform and Salesforce Platform One user licenses. Label is Standard.
  • PowerPartner: User whose access is limited because they’re a partner and typically access the application through a partner portalor Experience Cloud site. Label is Partner.
  • CSPLitePortal: user whose access is limited because they’re an org's customer and access the application through a Customer Portal or Experience Cloud site. Label is High Volume Portal.
  • CustomerSuccess: user whose access is limited because they’re an org's customer and access the application through a Customer Portal. Label is Customer Portal User.
  • PowerCustomerSuccess: user whose access is limited because they’re an org's customer and access the application through a Customer Portal. Label is Customer Portal Manager. Users with this license type can view and edit data they directly own or data owned by or shared with users below them in the Customer Portal role hierarchy.
  • CsnOnly: user whose access to the application is limited to Chatter. This user type includes Chatter Free and Chatter moderator users. Label is Chatter Free.
  • Guest: user whose access is limited because they’re an unauthenticated user without login credentials. Label is Guest.

See forth line:

    User notGuest = [Select Id
        From User 
        Where IsActive = true
        AND userType != 'Guest'
        Limit 1];            
    acc = new Account(
        Name = 'Test Account',
        OwnerId = NotU.id
    );
    Insert acc;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.