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
Forcedotcom737Forcedotcom737 

Solution to highlight text in call notes based on a list of words?

Any ideas on a SFDC.com based native solution (not buying third pary app's) that can scan call records / notes and identify keywords (based on a word list) in the call records. The solutions goal is to identify inappropriate words in call notes (e.g the word bribe).

Possible Solution (Need help with solving point 4 or open to completely new ideas):

1. Create a table / List / object with the word list that needs to be scanned (e.g the word 'bribe' would be in that list)
2. Export existing call record data into a database and perform a SQL join with 'word list' to identify calls with the word bribe (this will be a monthly process)
3. Load the suspect calls back into SFDC for examination by say managers / auditors etc

4. Is there a way to highlight the words that were picked up by the SQL process in the call notes that were identified as suspect. Perhaps a SFDC formatting class that maybe available. This is the part that I dont have an initial solution for. The goal is to make it easier for a manager to know which word caused the call note to be flagged without having to manually scan for words in the call note.

Also although this is not ideal are you aware of any third party solutions that can do this? 
Best Answer chosen by Forcedotcom737
KevinPKevinP
ForcedotCom737, here's a stab at solving this:

Create a custom setting (list type) with the Name and a custom field of "wrapper", 

Populate the custom setting with data like:

Name: "bribe"
Wrapper: '<SPAN STYLE="background-color: #ffffcc">bribe</SPAN>' 

Create a custom visualforce extension / page for displaying the call notes, and use something similar to this snippet of code to replace every instance of a word in the custom setting with it's wrapper value.
 
Public Static String highlightWords(String StringToHighlight) {
		Map<String, CustomSetting__C> keywords = CustomSetting__c.getAll();

		for (CustomSetting__c cs : keywords.values()) {
			if (StringToHighlight.contains(cs.Name)) {
				StringToHighlight = StringToHighlight.replaceAll(cs.Name, cs.Wrapper__C);
			}
		}
		return StringToHighlight;
	}

(Warning, I just spit that out off the top of my head, there may be syntax errors.)

All Answers

KevinPKevinP
ForcedotCom737, here's a stab at solving this:

Create a custom setting (list type) with the Name and a custom field of "wrapper", 

Populate the custom setting with data like:

Name: "bribe"
Wrapper: '<SPAN STYLE="background-color: #ffffcc">bribe</SPAN>' 

Create a custom visualforce extension / page for displaying the call notes, and use something similar to this snippet of code to replace every instance of a word in the custom setting with it's wrapper value.
 
Public Static String highlightWords(String StringToHighlight) {
		Map<String, CustomSetting__C> keywords = CustomSetting__c.getAll();

		for (CustomSetting__c cs : keywords.values()) {
			if (StringToHighlight.contains(cs.Name)) {
				StringToHighlight = StringToHighlight.replaceAll(cs.Name, cs.Wrapper__C);
			}
		}
		return StringToHighlight;
	}

(Warning, I just spit that out off the top of my head, there may be syntax errors.)
This was selected as the best answer
Forcedotcom737Forcedotcom737
Hi thanks for your response. I am very new to apex and visual force and could use some help understanding your suggestion. In your code as I am interpreting it you are going through the values in the custom setting and applying formatting (<span style>) to the values in the setting.Where are you going through the text in the call note? / How do you suggest this is done?