2

I'm trying to collect only those users who are ACTIVE and filter out non-active users. Can I filter out users from the following opportunityTeamQuery string that holds a query?

String opportunityTeamQuery = CUSTOMSETTING_Queries__c.getValues('CUSTOMSETTING_12').myQuery__c+' '+ 'where 
    (OpportunityAccessLevel =\''+ Opportunity Team +'\' or UserId =\''+oppor.ownerID+'\')and opportunityID=\''+oppor.id+'\''; 

where ...

myQuery__c=select OpportunityAccessLevel, UserId from OpportunityTeamMember

oppor = (Opportunity)controller.getRecord();
CL00203 value=edit

EDIT

I'm trying to retrieve active users only. How can I achieve this with this dynamic SOQL?

 String opportunityTeamQuery = CUSTOMSETTING_Queries__c.getValues('CUSTOMSETTING_12').myQuery__c+' '+ 'where (OpportunityAccessLevel =\''+ Opportunity Team +'\' or UserId =\''+oppor.ownerID+'\')and opportunityID=\''+oppor.id+'\''and User.IsActive=true;

where ...

myQuery__c=select OpportunityAccessLevel, UserId from OpportunityTeamMember

oppor = (Opportunity)controller.getRecord(); CL00203 value=edit 
1

Use the following query for to filter only active Team Members

Select o.User.IsActive, o.UserId, o.OpportunityId, o.Id From OpportunityTeamMember o where o.User.IsActive=true

You will have to just convert to dynamic query in your case

4
  • Thanks for answering. So what is "o"?
    – MnZ
    Jun 7 '14 at 16:13
  • 1
    its just variable you can remove all o's no problems.If the issue resolves mark as answered Jun 7 '14 at 16:21
  • i have made changes as per your reply. But getting an error Error: Compile Error: expecting a semi-colon, found 'and' at line 100 column 222 if I add like this.....String opportunityTeamQuery = CUSTOMSETTING_Queries__c.getValues('CUSTOMSETTING_12').myQuery__c+' '+ 'where (OpportunityAccessLevel =\''+ Opportunity Team +'\' or UserId =\''+oppor.ownerID+'\')and opportunityID=\''+oppor.id+'\''and User.IsActive=true; It will be very kind of you if u helped. Thanks
    – MnZ
    Jun 7 '14 at 19:43
  • 1
    Turn your logs on and debug .Looks like your query formation is missing proper syntax Jun 8 '14 at 1:55

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.