function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JBabuJBabu 

How to filter opportunity records?

Hi,

 

I have field called "WhatId" and it can have either account./opportunity/contact.. records.

I need to filter out opportunity records.

 

I tried using below query:

 

select id, subject,whatid, whoid from Task

where whatid like '006%'

 

I am getting error message "Invalid operator on id field". I tried using substring also, it didnot work.

 

Please let me know a way to identify opportunity records?

 

Thanks,

JBabu.

Best Answer chosen by Admin (Salesforce Developers) 
Nerd WhispererNerd Whisperer

Here's a link to basically the same problem you are having.

http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/apex/message-id/52350/print-single-message/false/page/1

 

This is a piece of their code on how to identify if the WhatId/WhoId is the same for
the desired record.

String leadKey = '00Q';
Id leadId;
String strWhoId = String.valueOf(e.whoId).substring(0 , 3);
     if(strWhoId == leadKey)
     {
          leadId = e.whoId;
     }

 

--------------------------------------------------------------

Need Help? Call 1-888-407-9578
or visit http://www.salesforcesuperheroes.com/

All Answers

Nerd WhispererNerd Whisperer

Here's a link to basically the same problem you are having.

http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/apex/message-id/52350/print-single-message/false/page/1

 

This is a piece of their code on how to identify if the WhatId/WhoId is the same for
the desired record.

String leadKey = '00Q';
Id leadId;
String strWhoId = String.valueOf(e.whoId).substring(0 , 3);
     if(strWhoId == leadKey)
     {
          leadId = e.whoId;
     }

 

--------------------------------------------------------------

Need Help? Call 1-888-407-9578
or visit http://www.salesforcesuperheroes.com/

This was selected as the best answer
JBabuJBabu

Thank you.