3

Here's the problem I need to solve. Let's say I have added 'Tesco' as a contact in my SalesForce. Over the years I have added hundreds and hundreds of notes detailing my correspondence with them (every email that is sent back and forth is saved as a note, as well as other things). Let's say I want to know whether at any point the word "spam" has been mentioned in the notes for this contact. How do I do it?

At the moment there only seems to be a "global search" option which would let me search for the word "spam" across all contacts, but I just want to search within that contact, and return a list of notes which mention the word. Is this at all possible?

Thanks!

3 Answers 3

2

I am not totally sure about that but in my oppinion the only solution is SOSL query.

try something like

FIND {Spam} IN Body
RETURNING Note (Name WHERE (Id = someId)

Also this might be helpful

http://www.salesforce.com/us/developer/docs/soql_sosl/salesforce_soql_sosl.pdf
2
  • Can you elaborate on that and/or give a sample SOSL query that illustrates the principal?
    – Mike Chale
    Commented Feb 4, 2014 at 15:56
  • Thanks for your answer. I am not familiar with SOSL. Where would I use this query? Could I paste this into the global search, or is this more at the database level? Would this return a list of notes where "spam" had been mentioned? Also, how would I find the ID of the customer I wanted to search on? Commented Feb 4, 2014 at 16:08
1

How about a SOQL for your problem?

This is the anatomy of the note object,

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_note.htm

  1. If you want to search only title of the note

You cannot use body of the note in the where clause as it is a textarea. So if you want to find spam in title, here is the SOQL for you.

SELECT id, title, body, ParentId from note where title like '%spam%' and parentId = 'Your contact id'
  1. If you want to search body also,

Run this in as anonymous code block,

for(Note mynote : [SELECT id, title, body, ParentId from note where parentId = 'Your contact id']) {
    if(mynote.body.contains('spam')) {
        System.debug(mynote.parentId);
    }
}

Hope this helps!

1

Basically - what BOSS_Force and Birthus are saying is that you have to write a custom VF page on the Contact record to get that information you are asking for. You can create a VF page and then embed it into a page layout.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .