You need to sign in to do that
Don't have an account?
Cannot filter using String.contains
the Apex class:
public with sharing class AcctActivityList{
public Account acct {get; set;}
public List<ActivityHistory> ClosedTasks {get; set;}
string mail = 'mail';
public AcctActivityList(ApexPages.StandardController stdcontroller) {
//get account
acct = (Account)stdController.getRecord();
//get activity history - can't query activity history directly, just in a subquery against another object
SObject[] ActivityHistory = [Select id, (select Id, AccountId, Account.Name, ActivityDate, ActivityType, Description, OwnerId, Subject,
LastModifiedDate, IsTask, WhatId, WhoId from ActivityHistories where
(ActivityType !='Email' or Subject.contains('email')) ORDER by ActivityDate DESC)
from Account where Id =: acct.id];
ClosedTasks = (List<ActivityHistory>)ActivityHistory.get(0).getSObjects('ActivityHistories');
}
}
Why is my string.contains filter not working (i.e. why can't I save the code)?
When I try to save, I get the error: unexpected token: 'email'. The same is true if the filter is Subject.contains('email') == false.
I've seen this string class referenced various places around the web and it's still not working. I also tried reverting to API 27 (it was on 29) in case there was a bug in that API. No go.
public with sharing class AcctActivityList{
public Account acct {get; set;}
public List<ActivityHistory> ClosedTasks {get; set;}
string mail = 'mail';
public AcctActivityList(ApexPages.StandardController stdcontroller) {
//get account
acct = (Account)stdController.getRecord();
//get activity history - can't query activity history directly, just in a subquery against another object
SObject[] ActivityHistory = [Select id, (select Id, AccountId, Account.Name, ActivityDate, ActivityType, Description, OwnerId, Subject,
LastModifiedDate, IsTask, WhatId, WhoId from ActivityHistories where
(ActivityType !='Email' or Subject.contains('email')) ORDER by ActivityDate DESC)
from Account where Id =: acct.id];
ClosedTasks = (List<ActivityHistory>)ActivityHistory.get(0).getSObjects('ActivityHistories');
}
}
Why is my string.contains filter not working (i.e. why can't I save the code)?
When I try to save, I get the error: unexpected token: 'email'. The same is true if the filter is Subject.contains('email') == false.
I've seen this string class referenced various places around the web and it's still not working. I also tried reverting to API 27 (it was on 29) in case there was a bug in that API. No go.
SObject[] ActivityHistory = [Select id, (select Id, AccountId, Account.Name, ActivityDate, ActivityType, Description, OwnerId, Subject,
LastModifiedDate, IsTask, WhatId, WhoId from ActivityHistories where
(ActivityType !='Email' or Subject like '%email%') ORDER by ActivityDate DESC)
from Account where Id =: acct.id];
http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_select_comparisonoperators.htm