You need to sign in to do that
Don't have an account?
and OR in where clause
I need the following to work, and I have writte it up to the AND clause, but I am trying to add a second kind of profile and need it to pick it up as well so what I have working is
List<Case> caseList = [SELECT Id, OwnerId
FROM Case
WHERE Id IN :caseIdList
AND Owner.Profile.Name = 'Customer Community User'];
But what I need to do is:
List<Case> caseList = [SELECT Id, OwnerId
FROM Case
WHERE Id IN :caseIdList
AND (Owner.Profile.Name = 'Customer Community User'
OR Owner.Profile.Name = 'Advanced Community User')];
but it keeps giving me errors on the syntax for this, how do i put the OR in there? Id IN :caseIdList has to apply to all, then EITHER other of the other two can be true and it should pull it to list.
Your query looks good:
I tried your scenario in workbench it works good:
Please check your profile name Advanced Community User.
I executed the below code:its works.
List<Id> caseIdList = new List<Id>();
for(case c:[Select Id,OwnerId,CaseNumber from Case])
{
caseIdList.add(c.Id);
}
system.debug('caseIdList-->'+caseIdList);
List<case> cases = [SELECT Id,OwnerId FROM Case WHERE Id IN : caseIdList AND (Owner.Profile.Name = 'System Administrator' OR Owner.Profile.Name = 'Custom Standard Platform User')];
System.debug('cases--->'+cases.size());
Output:
08:48:59.11 (16898034)|USER_DEBUG|[7]|DEBUG|caseIdList-->(50028000002Yt1NAAS, 50028000000noYdAAI, 50028000000noYeAAI, 50028000000noYfAAI, 50028000000noYgAAI, 50028000000noYhAAI, 50028000000noYiAAI, 50028000000noYjAAI, 50028000000noYkAAI, 50028000000noYlAAI, ...) 08:48:59.11 (21978655)|USER_DEBUG|[11]|DEBUG|cases--->32
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj
All Answers
your query looks good, try below method onces :
i hope it helps you.
kindly Let me inform if it helps you and close your query by choosing best answer if you got your right answer so it can helps others
thanks
sfdcmonkey.com
Your query looks good:
I tried your scenario in workbench it works good:
Please check your profile name Advanced Community User.
I executed the below code:its works.
List<Id> caseIdList = new List<Id>();
for(case c:[Select Id,OwnerId,CaseNumber from Case])
{
caseIdList.add(c.Id);
}
system.debug('caseIdList-->'+caseIdList);
List<case> cases = [SELECT Id,OwnerId FROM Case WHERE Id IN : caseIdList AND (Owner.Profile.Name = 'System Administrator' OR Owner.Profile.Name = 'Custom Standard Platform User')];
System.debug('cases--->'+cases.size());
Output:
08:48:59.11 (16898034)|USER_DEBUG|[7]|DEBUG|caseIdList-->(50028000002Yt1NAAS, 50028000000noYdAAI, 50028000000noYeAAI, 50028000000noYfAAI, 50028000000noYgAAI, 50028000000noYhAAI, 50028000000noYiAAI, 50028000000noYjAAI, 50028000000noYkAAI, 50028000000noYlAAI, ...) 08:48:59.11 (21978655)|USER_DEBUG|[11]|DEBUG|cases--->32
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj