0

I have this Page 1(screenshot 1) which is a list page. When user click on "Edit" button it will navigate to Page 2(screenshot 2) by using editCase method in the controller. But what is happening is when it goes to Site page 2 I am getting unauthorized error eventhough it is returning proper value. Is this possible to navigate between site URL's with ID value? From security perspective this URL will be accessible only in the defined IP range.

public class CaseListController {

private ApexPages.StandardController GstdController;
public Case internalCase  {get; set;}   
public boolean isNewMode {get; private set;}
public String cId {get;set;}

public CaseListController() {       
    getOpenCases();
}

public CaseListController(ApexPages.StandardController stdController)
{
    GstdController = stdController;        
    this.internalCase = (Case)GstdController.getRecord();

}

 public PageReference redirectToSubmitPage(){
    PageReference cEditPage = new PageReference(Label.CaseDetailSiteURL+'/'+'internalcaseSubmit');
    cEditPage.setRedirect(true);
    return cEditPage;
}


public PageReference editCase(){
    System.debug('editcase');
    System.debug('@@@showCaseId value is'+cId);
    PageReference cEPage = new PageReference(Label.CaseDetailSiteURL+'/'+'internalcaseSubmit?Id='+cId);
    System.debug('pagereference'+cEPage);
    cEPage.setRedirect(true);       
    return cEPage;

}

public PageReference cancelCase(){    
    PageReference cPage = new PageReference(Label.CaseDetailSiteURL+'/'+'internalcase');
    cPage.setRedirect(true);
    return cPage;
}

public PageReference viewCase(){
   String cRowId = String.valueOf(System.currentPageReference().getParameters().get('cId'));    
    System.debug('rowID value is'+cId);
  //  PageReference cPage = new PageReference(Label.CaseDetailSiteURL+'/'+'InternalCaseDetailPage');        
    PageReference cPage = new PageReference('https://cs94.salesforce.com/apex/InternalCaseDetailPage?Id='+cId);        
    cPage.setRedirect(true);
    return cPage;        
}

public List<Case> getOpenCases(){
    List<Case> openCases = [Select Id,CaseNumber,HasCommentsUnreadByOwner,LastModifiedDate,LastViewedDate,
                            Status,Subject,Priority,Description,Owner.Name,Contact.Name,CreatedDate,Type,
                            Sub_Type__c,Applicable_to_all_Merchant_Datum__c,Merchant_Name__c,Opportunity_Name__c
                            From Case Where IsClosed = false And RecordType.Name = 'Internal' ORDER BY CreatedDate Desc];
    return openCases;

}  }

    <---PAGE 1---apex:page standardController="Case" extensions="CaseListController" cache="false" >
    <apex:form >
       <apex:pageBlock id="caseResults"> 
            <apex:pageblockbuttons id="buttonsBlock">
                <apex:commandbutton value="New Case" action="{!redirectToSubmitPage}" />
            </apex:pageblockbuttons>
          <apex:pageBlockTable var="case" value="{!OpenCases}" id="tblResults" width="100%" >      
                <apex:column headerValue="Action" style="color:blue;" width="10%">
                    <!--apex:commandButton value="Edit" action="{!editCase}" reRender="tblResults"> 
                        <apex:param name="caseId" value="{!case.Id}" assignTo="{!cId}"/> 
                    </apex:commandButton-->
                    <apex:commandLink action="{!editCase}" value="Edit" styleClass="btn" style="color:black;text-decoration:none">
                     <apex:param assignTo="{!cId}" value="{!case.Id}" name="case_Id"/>
                    </apex:commandLink>                   
               </apex:column>                   
              <apex:column headerValue="Case Number" value="{!case.CaseNumber}"/>
              <apex:column headerValue="Case Owner" value="{!case.Owner.Name}"/>
              <apex:column headerValue="Contact Owner" value="{!case.Contact.Name}"/>
              <apex:column headerValue="CreatedDate" >
                  <apex:outputText value="{0,date,MM/dd/yy}"> 
                      <apex:param value="{!case.CreatedDate}" /> 
                  </apex:outputText>   
              </apex:column>                                        
              <apex:column headerValue="Status" value="{!case.Status}"/>
              <apex:column headerValue="Priority" value="{!case.Priority}"/>
              <apex:column headerValue="Type" value="{!case.Type}"/>
              <apex:column headerValue="Sub Type" value="{!case.Sub_Type__c}"/>
              <apex:column headerValue="Subject" value="{!case.Subject}"/>     
              <apex:column headerValue="Apply to all MD" value="{!case.Applicable_to_all_Merchant_Datum__c}"/>
              <apex:column headerValue="Merchant Name" value="{!case.Merchant_Name__c}"/>
              <apex:column headerValue="Opportunity Name" value="{!case.Opportunity_Name__c}"/>
              <apex:column headerValue="Comments" value="{!case.Description}"/>
          </apex:pageBlockTable>
       </apex:pageBlock> 
    </apex:form>  
</apex:page>



    <---Page 2--->
<apex:page standardController="Case" extensions="SubmitCaseController">
    <style type="text/css">
    .bPageBlock th.vfLabelColTextWrap {
      white-space: nowrap;   //added nowrap here
      position: relative;
    }
    .selectClass{
       width: 300px;
    }
   </style>
    <apex:form >
        <apex:pageBlock title="Submit New Case">
             <apex:pageblockbuttons location="top" >
                <apex:outputPanel id="buttons">
                    <apex:commandbutton value="Save" action="{!submitCase}" />                   
                    <apex:commandbutton value="Cancel" action="{!cancelCase}" />
                </apex:outputPanel>
            </apex:pageblockbuttons>
            <apex:pageBlockSection columns="2" title="Case Information" collapsible="false">
                <apex:pageBlockSection columns="1">
                    <apex:inputField label="Status" value="{!Case.Status}" style="text-align:left;width:50%"/>
                    <apex:inputField label="Priority" value="{!Case.Priority}" style="text-align:left;width:50%"/>
                    <apex:inputField label="Reason" value="{!Case.Reason}" style="text-align:left;width:50%"/>
                    <apex:pageBlockSectionItem labelStyle="width:30%">
                        <apex:outputLabel styleClass="labelCol first last" value="Merchant ID" for="merchant_Id"/>
                        <apex:inputText id="merchant_Id" value="{!merchantId}" style="text-align:left;width:50%"/>    
                    </apex:pageBlockSectionItem>
                    <apex:inputField label="Apply to All Merchant Datum" value="{!Case.Applicable_to_all_Merchant_Datum__c}" style="text-align:left;width:30%"/>                                  
                </apex:pageBlockSection>                             
                <apex:pageBlockSection columns="1">                     
                    <apex:pageBlockSectionItem dataStyle="text-align:left; width: 50%; max-width: 55%;">                    
                     <apex:outputLabel value="Sub Type" styleClass="labelCol first last" for="sub_type" >
                            <apex:selectList id="sub_type" value="{!sub_type}" size="1" multiselect="false" >
                                <apex:selectOptions value="{!subType}"/>
                            </apex:selectList>
                        </apex:outputLabel>
                    </apex:pageBlockSectionItem>                 
                     <apex:pageBlockSectionItem dataStyle="text-align:left; width: 50%; max-width: 55%;">                                          
                    <apex:outputLabel value="Type" styleClass="labelCol first last" for="type" >
                        <apex:selectList id="type" value="{!c_type}" size="1" multiselect="false"  >
                            <apex:selectOptions value="{!type}"/>
                        </apex:selectList>
                    </apex:outputLabel>
                    </apex:pageBlockSectionItem>
                     <apex:outputLabel value="Owner Name" styleClass="labelCol first last" for="o_name">
                        <apex:selectList id="o_name" value="{!owner_name}" size="1" multiselect="false" >
                            <apex:selectOptions value="{!oName}"/>
                        </apex:selectList>
                    </apex:outputLabel>
                    <apex:outputLabel value="Contact Name" styleClass="labelCol first last" for="con_name">
                        <apex:selectList id="con_name" value="{!contact_name}" size="1" multiselect="false" style="margin-top: -8pt;">
                            <apex:selectOptions value="{!cName}"/>
                        </apex:selectList>
                    </apex:outputLabel>                    
                </apex:pageBlockSection>                
            </apex:pageBlockSection>
            <apex:pageblocksection title="Additional Information" collapsible="false" columns="2">
                <apex:pageBlockSection columns="1">
                    <apex:inputField label="Subject" value="{!Case.Subject}" style="text-align:left;width: 300px; height: 10px"/>
                    <apex:inputField label="Comments" value="{!Case.Description}" style="text-align:left;width: 500px; height: 100px"/>
                </apex:pageBlockSection>
            </apex:pageblocksection>                 
        <apex:pageBlockSection title="Upload a Attachment" collapsible="false">
         <apex:pageBlockSectionItem >
             <apex:outputLabel value="File" for="file_File"/>
             <apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}"/>
         </apex:pageBlockSectionItem>
        </apex:pageBlockSection>  
        </apex:pageBlock>

    </apex:form>
</apex:page>

enter image description here

enter image description here

enter image description here

enter image description here

  • Try it using the /apex/ url with regular SF user. If that works the it is a permissions issue. If it does not work you will be able to see the error – Eric Jun 3 '18 at 22:11
  • using apex/url it works. I also verified the permission on the site user profile and it has all the permission. I was able to submit the case submission successfully. – user28452 Jun 3 '18 at 23:35
  • If it works with full SF user and not site it’s a permissions issue somewhere. Check page security as well – Eric Jun 3 '18 at 23:37
  • I have seen this error when there is an exception in your code that processes the redirect page, not in the code that submits the redirect and not a permissions issue – cropredy Jun 4 '18 at 1:34
  • Ok. I couldn't find any error from the code nor in the debug log. And I couldn;t get around this error as well :( – user28452 Jun 4 '18 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.