How to fine tune Knowledge article auto-suggestion on case creation - Story From: Recent Ideas

With Summer’10 release, Knowledge gains the ability to auto-suggest relevant articles upon case creation.
Just like when searching Knowledge from a case details, the search uses only the case subject and this search can be fine tuned with the same kind of customization.

The idea is to highjack the page flow after the case creation by using the undocumented/unsupported URL parameter saveUrl, to redirect to a intermediate page that will run a background search. If this search detects relevant articles, it will redirect the user to the knowledge search page instead of the case detail page.

Let’s have a look first to this intermediate page, and we will see after how to “plug” it in the process.
The page, let’s name it knowledgeArticleAutoSuggest, is really simple:

<apex:page controller="knowledgeArticleAutoSuggestController" action="{!redirect}">
    Searching if there are relevant articles to that newly created case (case id: <apex:outputText value="{!newId}" />)
</apex:page>



As you can see with the redirect parameter on the first line, all the “magic” happens in the custom controller used by this page.
This custom controller (below) detects first if there is a parameter “newId” that will indicates that the case to display is new. In that case, it has a bit of logic in order to, first map a case attribute to data categories (you will have to modify this part to fit your configuration) and then runs a “silent” search to check if there are any relevant articles in Knowledge. If there are some, then the controller redirects the user to the articles search page rather than to the new case details.

public class knowledgeArticleAutoSuggestController {

    private Case thecase;
    private boolean isNew;
    private String newId;
   
    public knowledgeArticleAutoSuggestController() {
        isNew = false;

        // if a newId parameter is received
        newId = ApexPages.currentPage().getParameters().get('newid');
        if (newId.length()>0) {
            isNew = true;
            this.thecase = [select id, subject, type, product__c from Case where id = :newId];
        }
    }
   
    public String redirect() {
        // article search page URL
        String caseUrl = '/' + newId;
        // case detail page URL
        String searchUrl = '/knowledge/knowledgeHome.apexp';

        if (isNew) {
           
            // ID of the current case
            searchUrl += '?id=' + newId;
           
            // use the case subject as the keywords to search for
            String kw = thecase.Subject;
            searchUrl += '&search=' + thecase.Subject;
           
            // read some case attributes
            String caseType = thecase.Type;
            String caseProduct = thecase.Product__c;
           
            // preselect some data category for better search results depending on which product the case is related to
            String product = '';
            if (caseProduct!=null) {
                if (caseProduct.startsWith('iPhone'))
                   product = 'iPhone';
                if (caseProduct.startsWith('iPod'))
                   product = 'iPod';
                if (caseProduct.startsWith('iPad'))
                   product = 'iPad';
               
                if (product.length()>0)
                   searchUrl += '&ct_Product=' + product;
            }
           
            // run a background search to determine if some relevant articles exists
            String query = 'FIND \'' + kw + '\' RETURNING KnowledgeArticleVersion (id WHERE PublishStatus=\'online\')';
            if (caseProduct!=null)
                query += ' WITH DATA CATEGORY Product__c BELOW ' + product + '__c';
            List<List<SObject>> searchList = search.query(query);
            KnowledgeArticleVersion [] articles = ((List<KnowledgeArticleVersion>)searchList[0]);

            // no article returned, redirecting to the case details
            if ( articles.size()==0)
                return caseUrl;
           
            // once the business logic has been executed, we still need to go to the article search page
            return searchUrl + '&isCaseCreation=1';
        } else {
            return caseUrl;
        }
    }
}



The missing piece is the override of the new case action. The idea is to override this action so that we can add the  saveUrl parameter that will be used to change the page flow after the new case has been saved (see above).


Let’s create a new page, named NewCaseOverride:

<apex:page >
    <script type = "text/javascript">
        window.location = "/500/e?retURL=%2F500%2Fo&ent=Case&saveURL=%2Fapex%2FknowledgeArticleAutoSuggest&nooverride=1";
    <script>
</apex:page>



Now navigate to Setup>App Setup>Cases>Buttons and Links, and Edit the standard button New. You should be able to select the NewCaseOverride page.

Before testing, you should grant access to the new pages and the new class for the profiles you are enabling the feature for.

Notes:

  1. As mentioned earlier saveUrl “hacking” is not supported by Salesforce, there maybe be some issues with futures upgrades
  2. If you are using several case record types, then you may have to add more logic in NewCaseOverride page



Let us know how this works for you!

CRM Software Free Trial – Your CRM online guide to Web-based Contact Management Software Free Internet Trials and the latest news, article, reviews & comparisons.



CRM Software Free Trial – Your CRM online guide to Web-based Contact Management Software Free Internet Trials and the latest news, article, reviews & comparisons.

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

“We here at the “Web-Based Contact Management Software News, Reviews” are posting for your consumption the latest blog posts from the major Web-Based CRM Software vendors around the world who are focused on the development of products that enhance your CRM experience.” enjoy :)

——————————

Post Name:
How to fine tune Knowledge article auto-suggestion on case creation – Story From: Recent Ideas
*
If Needed – To Read the Full Story: (post’s here may be limited by vendor’s RSS feed) – Highlight above post’s blue title, right click and search with google.

Listed Related posts:

  1. How to fine tune Knowledge articles search from a case - Story From: Popular Ideas When searching Knowledge articles from a case, by default only the case title is used for the search. Often we want to use more information from the case in order to have more accurate search...
  2. The Quick Email Button, revisited for sending Knowledge articles - Story From: Recent Ideas The Quick Email Button from the excellent werewolf, describe and to save clicks for your agents by provide a custom button that will launch directly the email editor from your case details page. Unfortunately, this customization...
  3. Case Deflection tips and tricks with Salesforce Knowledge - Story From: Popular Ideas One way to increase your case deflections is to allow your customers to self-solve their support questions with knowledge articles. The numbers of case deflections can be multiplied by the cost per support case. For...
  4. How do I reduce the number of people with View All Data permission? - Story From: Recent Ideas I had this question come up today: "We have over one hundred people in our org with View All Data. This is too many and represents a potential security risk. How can I reduce the number...
  5. Prevent Cherry-Picking On Cases And Leads With The Get Next Button - Story From: Recent Ideas Service Cloud customers sometimes tell me that they have a problem with their agents cherry-picking cases and leads.  They use assignment rules to assign the objects to queues, but once they're in queues, the agents look...
  6. Inside Salesforce Knowledge (2): Data categories, article categorization and… - Story From: Recent Ideas Inside Salesforce Knowledge (2): Data categories, article categorization and knowledge base security In that post, I will explore the other very structuring feature of Salesforce Knowledge: data categories.   What are data categories Data categories ......
  7. Autocreating A Contact From Web To Case Or Email To Case - Story From: Popular Ideas Today's post is not for everyone.  There's a very good reason why Salesforce.com does not autocreate contacts from Web To Case or Email To Case, and that reason is that one generally does not know enough...
  8. What can Modify All Data really do? - Story From: Recent Ideas I had this question come up last Friday: "What can Modify All Data really do?" We all know this permission to mean, "system administrator".  But we rarely look at the detail of what makes up the...
  9. First Custom Report Type Creation - Story From: Popular Ideas Custom Report Types The first step to using the new reporting features in Summer'07 is to create a Custom Report Type. I'm going to show you how to create a simple one and bring in extra...
  10. Summer ‘10 Release: Check out what the Chatter’s all about! - Story From: Recent Ideas Summer ’10 brings new and exciting ways to collaborate within your organization as well as with your customers. With Salesforce Chatter, you can bring the best of social networking to your enterprise applications to connect and...