• Parmanand Shete
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi Guys,

I am getting this error while inserting user in the test class.
System.DmlException: Insert failed. role type must match user type.

Please find the below code.

 Set<String> customerUserTypes = new Set<String> {'CSPLiteUser', 'PowerPartner', 'PowerCustomerSuccess',   'CustomerSuccess'};
        Profile portalProfile = [SELECT Id FROM Profile WHERE UserType in :customerUserTypes Limit 1];
        UserRole role = [Select Id From UserRole Where PortalType = :'CustomerPortal' Limit 1];
        User user1 = new User(
            Username = System.now().millisecond() + 'test12345@test.com',
            ContactId = contact1.Id,
            ProfileId = portalProfile.Id,
            UserRoleId = role.Id,
            Alias = 'test56',
            Email = 'test12345@test.com',
            EmailEncodingKey = 'UTF-8',
            LastName = 'McTesty',
            CommunityNickname = 'test12345',
            TimeZoneSidKey = 'America/Los_Angeles',
            LocaleSidKey = 'en_US',
            LanguageLocaleKey = 'en_US'
        );
    Database.insert(user1);


 
I want get a list of all the users who are part of public group of the currently logged in user. In documentations, i have read that  able to pick these values from group and group member objects.

A record exists for every User or Group who is a direct member of a public group whose Type field is set to Regular. User records that are indirect members of Regular public groups are not listed as group members. A User can be an indirect member of a group if he or she is in a UserRole above the direct group member in the hierarchy, or if he or she is a member of a group that is included as a subgroup in that group.

Can we get all users of a group using group id? Please help me ASAP it's urgent.

Hi friends,

 

 Can u pls help me to get all queuemembers in Queue?

 

 Is there any SOQL query to get this! pls Help me regarding this........

 

 

 Thank U

Sfdcbluefish