0

MALFORMED_QUERY: Opportunity__r.LeadSource != 'Website'); ^ ERROR at Row:3:Column:89 unexpected token: ;

SELECT Id, OwnerId, WhatId,Reminder_Date_Time__c, WhoId,Record_Type_Name__c, Task_Type__c,
       Assigned_Date__c, Task_Status__c, ActivityDate, Subject, Attended_By__c,Is_Assigned__c 
FROM Task 
WHERE (Task_Status__c != 'Closed') AND ( Opportunity__r.LeadSource != 'Website')
  • Please clarify your question. Your title mentions NOT LIKE but you do not have NOT LIKE in your query. – David Cheng Nov 22 '18 at 6:48
1

SOQL queries do not end with a semi-colon. Please remove the semi-colon from the end of your query. The parentheses are also optional.

SELECT Id, OwnerId, WhatId,Reminder_Date_Time__c, WhoId,Record_Type_Name__c, Task_Type__c,
       Assigned_Date__c, Task_Status__c, ActivityDate, Subject, Attended_By__c,
       Is_Assigned__c 
FROM Task 
WHERE Task_Status__c != 'Closed' AND Opportunity__r.LeadSource != 'Website'
  • r8 @sfdcfox but it's give me wrong results – user61059 Nov 22 '18 at 10:06
  • @user61059 how so? That wasn't in your question. – sfdcfox Nov 22 '18 at 10:09
0

You can try this dynamic soql.

String query = 'SELECT Id, OwnerId, WhatId, Reminder_Date_Time__c, WhoId, Record_Type_Name__c, Task_Type__c, Assigned_Date__c, Task_Status__c, ActivityDate, Subject, Attended_By__c,Is_Assigned__c '+
               +'FROM Task '+
               +'WHERE Task_Status__c != \'Closed\' AND (NOT Opportunity__r.LeadSource LIKE \'%Website%\')';
System.debug(query);

Refer this link for more details http://raydehler.com/cloud/clod/soql-sosl-using-not-like.html

For more on Quoted String Escape Sequences

  • it shows unexpected token NOT – user61059 Nov 22 '18 at 10:56
  • SELECT Id, OwnerId, WhatId,Reminder_Date_Time__c, WhoId, Record_Type_Name__c, Task_Type__c,Assigned_Date__c, Task_Status__c, ActivityDate, Subject, Attended_By__c,Is_Assigned__c FROM Task WHERE ( Task_Status__c LIKE 'Open') AND( NOT Opportunity__r.LeadSource LIKE 'Website') ***************************************************************************************************** i tried this one but it's not working with my DB records – user61059 Nov 22 '18 at 10:56
  • @user61059 Try the updated query – Reshma Nov 23 '18 at 5:52
  • with one like and not equal operator it's works by removing parentheses in LIKE condition – user61059 Nov 23 '18 at 6:22
  • But if i write SELECT Id, OwnerId, WhatId,Reminder_Date_Time__c, WhoId, Record_Type_Name__c, Task_Type__c,Assigned_Date__c, Task_Status__c, ActivityDate, Subject, Attended_By__c,Is_Assigned__c FROM Task WHERE (NOT Task_Status__c LIKE 'Closed') AND( Opportunity__r.LeadSource != 'Website') .. Still i m getting wrong results – user61059 Nov 23 '18 at 6:24

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.