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
MATTYBMEMATTYBME 

VF New Case on Submit does not send to Suggested Solutions

So what I failed to take into account was the fact that normally on Case Submission  (on Customer Portal with the Enable Suggested Solutions on Case Submission checkbox enabled on Portal Settings) if there was a Solution that was applicable to the Case it would send the user to a page where they could view the suggested Solutions and drill into the specific Solution and Close their own Case if the Solution resolved the Case by selecting Yes the Solution was Helpful. This would close the Case.

Obviously I missed this component in building the new Case pages in Visualforce and am not sure how to include it using VF.

VF New case code looks like this:

Code:
<apex:page standardController="case" tabstyle="trouble_tickets__tab">
<apex:sectionHeader title="Trouble Tickets" subtitle="New Trouble Ticket"/>
<apex:form >
<apex:pageBlock title="New Trouble Ticket">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Submit" />
<apex:commandButton action="/p/attach/NoteAttach—pid=50080000005ulLn&retURL=%2Fui%2Fsolution%2FSolutionSuggestionPage%3Fcaseid%3D50080000005ulLn%26autoredirected%3D1" value="Submit & Add Attachment" />
<apex:commandButton action="/apex/CustomerPortalCaseHomePage" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Trouble Ticket Details" columns="1">
<apex:inputField value="{!case.priority}" />
<apex:outputField value="{!case.status}">
<apex:outputText ><font style="color:red">New</font></apex:outputText>
</apex:outputField>
<apex:inputField value="{!case.subject}" style="width: 400px;"/>
<apex:inputField value="{!case.description}" style="width: 700px; height: 100px;"/>
<apex:outputField value="{!case.Resolution__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection >
<c:CaseQuickTipsGuideComponent />
<c:CaseAttachmentsInstructions />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

And the URL for a Case submitted using the standard New Case page that suggests a Solution is this:

https://na6.salesforce.com/ui/solution/SolutionSuggestionPage—caseid=50080000005v4nB&autoredirected=1

 How do I build into my VF page the right code to make sure that those Cases submitted where there maybe a relevant Solution that the page redirects through to the Suggested Solutions page?


Message Edited by MATTYBME on 01-07-2009 02:28 PM
EricVlachEricVlach
One possible solution:
create an apex class with the save action that overrides the default action (reference it with <apex:page extensions="solutionPageControllerExtension">).

public class solutionPageControllerExtension {
    public solutionPageControllerExtension (ApexPages.StandardController controller){
    }
    public PageReference save() {
        insert case;
        PageReference solutionPage = new PageReference('/ui/solution/SolutionSuggestionPage—caseid=' + case.Id + 'autoredirected=1');
        solutionPage.setRedirect(true);
        return solutionPage;
    }
}


(... still havn't figured out how to disable those smileys)
MATTYBMEMATTYBME
Thanks. I did indeed build an extension controller very similar.

 
Code:
public class CustomerPortalNewCaseExtension { 

    private ApexPages.StandardController controller;
    private Case c;
    public CustomerPortalNewCaseExtension(ApexPages.StandardController controller) {
        this.controller = controller;
    }
    public PageReference viewSuggestionSave() {
        controller.save();
        c = (Case)controller.getRecord();
        return new PageReference('/ui/solution/SolutionSuggestionPage—caseid=' + c.Id + '&autoredirected=1');
    }
    public PageReference viewSuggestionSaveAdd() {
        controller.save();
        c = (Case)controller.getRecord();
        return new PageReference('/p/attach/NoteAttach–pid=' + c.Id + '&retURL=/ui/solution/SolutionSuggestionPage˜caseid=' + c.Id + '&autoredirected=1');
    }
    static testMethod void testCustomerPortalNewCaseExtension() {
        Case testCase = new Case();
        testCase.Subject = 'Test Subject';
        testCase.Priority = 'Medium';
        testCase.Description = 'Test Description';
        insert testCase;
        
        ApexPages.StandardController caseController = new ApexPages.standardController(testCase);
        CustomerPortalNewCaseExtension caseExt = new CustomerPortalNewCaseExtension(caseController);
        PageReference theRef = caseExt.viewSuggestionSave();
        System.AssertEquals('/ui/solution/SolutionSuggestionPage™autoredirected=1&caseid=' + testCase.Id,theRef.getUrl());
        
        theRef = caseExt.viewSuggestionSaveAdd();
        System.AssertEquals('/p/attach/NoteAttach?autoredirected=1&pid=' + testCase.Id + '&retURL=%2Fui%2Fsolution%2FSolutionSuggestionPage%3Fcaseid%3D' + testCase.Id,theRef.getUrl());

    }
 }

 
It seems the only way to bypass getting those pesky smiley's is to put all code in the src box.





Message Edited by MATTYBME on 01-08-2009 11:27 AM