I need to consult Salesforce records that where created in the last 7 days, but when I test the email it appears the following error:

Call to retrieve records for salesforceobject Questionario__c failed! Error in the application.
API Fault: Salesforce.com Fault thrown.
Exception Type:MalformedQueryFault
Exception Message: '0010U000003EkpkQAC' AND LastModifiedDate > 12/25/2017 4:31:35 ^ ERROR at Row:1:Column:223 unexpected token: / At row:1 and column: 223


set @id = Id

set @today = now()

set @setedias = dateadd(@today,'-6','D')

set @Questfinalizado1 = retrievesalesforceobjects('Questionario__c','Pesquisador__c,Status_do_Questionario__c,LastModifiedDate','Status_do_Questionario__c','=','Pendente de Análise VIDI','Pesquisador__c','=',@id)

set @Questfinalizado2 = retrievesalesforceobjects('Questionario__c','Pesquisador__c,Status_do_Questionario__c,LastModifiedDate','Status_do_Questionario__c','=','Em Aprovação','Pesquisador__c','=',@id)

set @Questfinalizado3 = retrievesalesforceobjects('Questionario__c','Pesquisador__c,Status_do_Questionario__c,Data_alteracao_status__c,LastModifiedDate','Status_do_Questionario__c','=','Aprovado','Pesquisador__c','=',@id,'LastModifiedDate','>',@setedias)

set @countfinalizado1 = rowcount(@Questfinalizado1)

set @countfinalizado2 = rowcount(@Questfinalizado2)

set @countfinalizado3 = rowcount(@Questfinalizado3)

set @totalfinal = add(@countfinalizado1,@countfinalizado2)

set @totalfinalizado = add(@totalfinal,@countfinalizado3)


When I test it whithout the 'LastModifiedDate','>',@setedias criteria it runs normally.

Am I doing something wrong?


try hard fixing a date on setedias and see if that works (try different formats and values:

set @setedias = '01/01/2018'

if passing in a hardcoded date works (if you find a working format) then you're going in the right direction. Then you could play about with a FormatDate function.

set @setedias = formatdate(dateadd(@today,'-6','D'), "MMM dd, yyyy", "HH:mm:ss.tt", "en-US")

My gut tells me it's something to do with your date format lookup on LastModifiedDate


Try this:

set @setedias = FORMATDATE(dateadd(@today,'-6','D'), "yyyy-mm-ddTHH:mm:ss.000Z")

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.