You need to sign in to do that
Don't have an account?
ekm
Flex Query SalesForce based on range of dates
Hi all,
I'm attempting to query a table (Events) based on a range of dates and another field (in this example, it's ffCompany_Name1__c within the Events table I'm using). The id of the dateField I'm using is dateStartDateMainEditMeeting.
I'm receiving a 1009 error with the code below.
Anyone have any suggestions what I can do query a table based on an ActivityDate? Thanks in advance for anyone's help.
public var dSource:String = dateStartDateMainEditMeeting.text;
public var dStartEdit:Date = Util.stringToDate(dSource);
private function displayEditMeetingSearchResults():void
{
currentState="editMeetingSearchResults";
var acc:SObject = new SObject('Event');
apex.query("Select Id, " +
"ffCompany_Name1__c, " +
"ffCompany_Name2__c, " +
"ActivityDate, " +
"ActivityDateTime, " +
"Method__c, " +
"ActivityEndTime__c, " +
"Type, " +
"Objectives__c, " +
"Subject, " +
"Actual_Outcome__c, " +
"Travel_Time__c From Event where ffCompany_Name1__c like '%Bank%' and ActivityDate >= '" + dateStartDateMainEditMeeting.text + "'",
new AsyncResponder(function (qr:QueryResult):void
{
for (var j:int=0;j<qr.records.length;j++)
{
events.addItem( {ffCompany_Name1__c:qr.records[j].ffCompany_Name1__c, ffCompany_Name2__c:qr.records[j].ffCompany_Name2__c, Type:qr.records[j].Type, ActivityDate:qr.records[j].ActivityDate, ActivityDateTime:qr.records[j].ActivityDateTime, Objectives__c:qr.records[j].Objectives__c } );
}
}
) // closes new AsyncResponder(function (qr:QueryResult):void
); //closes 1st apex query
}
I'm attempting to query a table (Events) based on a range of dates and another field (in this example, it's ffCompany_Name1__c within the Events table I'm using). The id of the dateField I'm using is dateStartDateMainEditMeeting.
I'm receiving a 1009 error with the code below.
Anyone have any suggestions what I can do query a table based on an ActivityDate? Thanks in advance for anyone's help.
public var dSource:String = dateStartDateMainEditMeeting.text;
public var dStartEdit:Date = Util.stringToDate(dSource);
private function displayEditMeetingSearchResults():void
{
currentState="editMeetingSearchResults";
var acc:SObject = new SObject('Event');
apex.query("Select Id, " +
"ffCompany_Name1__c, " +
"ffCompany_Name2__c, " +
"ActivityDate, " +
"ActivityDateTime, " +
"Method__c, " +
"ActivityEndTime__c, " +
"Type, " +
"Objectives__c, " +
"Subject, " +
"Actual_Outcome__c, " +
"Travel_Time__c From Event where ffCompany_Name1__c like '%Bank%' and ActivityDate >= '" + dateStartDateMainEditMeeting.text + "'",
new AsyncResponder(function (qr:QueryResult):void
{
for (var j:int=0;j<qr.records.length;j++)
{
events.addItem( {ffCompany_Name1__c:qr.records[j].ffCompany_Name1__c, ffCompany_Name2__c:qr.records[j].ffCompany_Name2__c, Type:qr.records[j].Type, ActivityDate:qr.records[j].ActivityDate, ActivityDateTime:qr.records[j].ActivityDateTime, Objectives__c:qr.records[j].Objectives__c } );
}
}
) // closes new AsyncResponder(function (qr:QueryResult):void
); //closes 1st apex query
}
<mx:DateFormatter id="DateDisplay"
formatString="YYYY-MM-DD"/>
When forcing a date such as 2008-05-01, everything works fine.
Here's the dateField column that I'm using to enter the date I want to query:
<mx:DateField id="dateStartDate"
labelFunction="formatDate2" parseFunction="null"/>
And the label function getting called:
private function formatDate2(date:Date):String {
return DateDisplay.format(date);
}
Using either dStartEdit or dateStartDateMainEditMeeting.text within my query string for ActivityDate causes a null error.
The column in the datagrid where I want to display the date resulting from the query:
<mx:DataGridColumn headerText="Date" dataField="ActivityDate" width="100"
labelFunction="formatDate"/>
And the labelFunction:
private function formatDate(item:Object, column:DataGridColumn):String
{
return DateDisplay.format(item.ActivityDate);
}
Hope this is what you were looking for and thanks again.