0

I have a query and I am fetching record based upon a single profile but I want to append one more profile along with this query. So that I can get both the profile record in a single query.

 UserData = [Select u.Name From User u where IsActive = true and Profile.Name = 'Service Marketing' ORDER BY Name ASC NULLS LAST];            
0

As far as I am understanding, you want to filter the records based on another profile. If that is what you are asking, then you can add the OR clause to your SOQL query and filter the records.

UserData = [Select u.Name From User u where IsActive = true and (Profile.Name = 'Service Marketing' OR Profile.Name = 'System Administrator') ORDER BY Name ASC NULLS LAST];

If you want to get the Profile information along with the User record, then you can use the relationship query and get the Profile information.

UserData = [Select u.Name,Profile.Name, Profile.UserLicenseId, Profile.Description From User u where IsActive = true and (Profile.Name = 'Service Marketing' OR Profile.Name = 'System Administrator') ORDER BY Name ASC NULLS LAST];

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.