Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I want to add custom links to the solutions on the Self-service portal. These links will say "Please indicate if it's an useful solution: Yes / No. I'm wondering if it's possible to add a counter to the solution itself that indicates how many users clicked on "Yes" vs clicked on "No". The standard functionality ("Does this Solution help you answer your question?") on the SSP doesn't give me any indication if the solution is popular or not.

share|improve this question
add comment

3 Answers

You can't do this I'm afraid. The self-service portal doesn't allow you to publish a form that the user can interact with. The SSP is intentionally very restricted (and not available to new organizations) as there is no charge for a user license.

The best that you can do I would think is embed a couple of links in the solution (yes/no) that point to a visualforce page on an unauthenticated Force.com site, which updates a counter. I've created a basic implementation on my Force.com site and proved that the concept works. The page is:

    <apex:page controller="UpdateSolutionController">
  <apex:form >
   <apex:actionFunction name="update" action="{!updateSolution}" rerender="svd" status="stat"/>
   <apex:outputPanel id="svd">
     <apex:outputPanel rendered="{!saved}">
       Saved
     </apex:outputPanel>
   </apex:outputPanel>
  </apex:form>
   <script>
   function addLoadEvent(func) 
{ 
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') 
  { 
     window.onload = func; 
  } 
  else
  { 
      window.onload = function()  
      { 
        if (oldonload) 
        { 
           oldonload(); 
        } 
        func(); 
      } 
   } 
} 

addLoadEvent(function()  {
   update();
   });
   </script>
</apex:page>

this simply creates an actionfunction to execute a method in the controller, and appends an onload handler to execute it. Once that has completed the 'saved' message appears.

and the controller:

public class UpdateSolutionController 
{
    private Id solId {get; set;}
    private Boolean yes {get; set;}
    public Boolean saved {get; set;}

    public UpdateSolutionController()
    {
        solId=ApexPages.currentPage().getParameters().get('solutionId');
        yes=(null!=ApexPages.currentPage().getParameters().get('yes'));
        saved=false;
    }

    public PageReference updateSolution()
    {
        List<Solution> solns=[select id, Yes_Count__c, No_Count__c from Solution where id=:solId];
        if (solns.size()>0)
        {
            Solution soln=solns[0];
            if (yes)
            {
                if (null==soln.Yes_Count__c)
                {
                    soln.Yes_Count__c=0;
                }
                soln.Yes_Count__c++;
            }
            else
            {
                if (null==soln.No_Count__c)
                {
                    soln.No_Count__c=0;
                }
                soln.No_Count__c++;
            }
            update soln;
        }

        saved=true;

        return null;
    }
}

This pulls the solution id and whether its a yes/no from the URL, locates the solution and updates it. Thus if I hit my page with the URL:

http://kbtutorial-developer-edition.na6.force.com/updatesolutioncount?solutionid=50180000000SOa5

the no count is updated.

There is a security hole here, in that the record is updated without the user taking any action, so this could be used for a Cross Site Request Forgery attack. That said, the worst that can happen is the figures are gamed so its not a huge worry.

share|improve this answer
    
I'm looking to use those fields ("Counter of Yes" and "Counter of No") internally, so they don't need to be visible to the SSP. Do you have an example to this custom controller? –  Itay B Nov 13 '12 at 14:27
    
I've updated my answer with a basic implementation that I've tested on one of my developer org sites. –  Bob Buzzard Nov 13 '12 at 15:19
    
nice, thank you! is there a way to authenticate the force.com site (So it could be accessed only be Self-service portal users), or it's whole purpose is to be visible to all? –  Itay B Nov 15 '12 at 15:04
    
You can have login enabled for a force.com site. However, the site user will be disconnected from the self-service portal users as they are different licenses. –  Bob Buzzard Nov 15 '12 at 15:44
add comment

You can construct the link as a shortcut to a Visualforce page which the portal users have access to.

Eg a custom URL field on Solution or just a Custom Link, which points to

/apex/IncrementSolutionCount?id={!Solution.id}

This page then on load invokes an action method in the controller which increments the count of the solution.

<apex:page controller="IncrementSolutionController" action="{!incrementSolutionCount}" >
share|improve this answer
    
i think the only option is adding custom link to the solution body, as custom fields are not supported at the Self-Service...what's the best way to pass the Solution ID? –  Itay B Nov 13 '12 at 14:25
add comment
up vote 0 down vote accepted

Apperantly this information is visible on solution report (It's only visible there...not on list views, solution page layout or API). It contains 3 fields: "Self-Service Access Count", "Self-Service Answer Count" and "Self-Service Positive Count". However, I'll use the answers suggested above for other improvements in the SSP.

Thanks

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.