Find your content:

Search form

You are here

Custom Link to Update Field on Solutions

 
Share

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.


Attribution to: Itay B

Possible Suggestion/Solution #1

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}" >

Attribution to: techtrekker

Possible Suggestion/Solution #2

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.


Attribution to: Bob Buzzard

Possible Suggestion/Solution #3

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


Attribution to: Itay B
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4344

My Block Status

My Block Content