+ Start a Discussion
Force2b_MikeForce2b_Mike 

Strange Behavior on Overridden View/Edit link for Portal Users logging in via a Sites page

I have a Customer Portal where I've created a Site for the users to login from. This problem only appears when logging into the Portal via the Site. If they login using the standard Portal URL there is no problem, but of course we want the users to login via the Sites page.

 

If I override the VIEW or EDIT links on a Custom Object, when the user clicks the EDIT link or the item NAME in a View, they get an error for "Page Not Found" (the error below is a VIEW link error):

 

Page Not Found: /portalpage/a1CQ0000000ouMS/e 

 

If I remove the override for the VIEW, when the user clicks the link it opens up the page properly, and it even shows the exact same URL that appeared in the error message.

 

Very bizzarre. The page exists either way, but for some reason the overridden link is creating an issue.

 

I confirmed that the VisualForce page used in the override is available to the Portal User and Sites user Profiles and checked any other security setting I can think of. Doesn't seem to be a security setting, especially given the odd page not found error, but who knows.

 

Is there a way I can override the VIEW/EDIT page for a Custom Object and have that override work for Portal Users that login via a Sites page?

 

 

Best Regards,

 

Mike

Force2b_MikeForce2b_Mike

I was able to find a creative work-around for this. In general, I did not want to rebuild every list and page using VisualForce just to get the links to work on my portal-site. So, to work-around the PageNotFound error, I created a custom PageNotFound VisualForce page that detects the "error" and just redirects the user to the correct page:

 

 

<apex:page showHeader="false" title="{!$Label.site.file_not_found}" >

<script>

String.prototype.startsWith = function(s) { if( this.indexOf(s) == 0 ) return true; return false; }
String.prototype.endsWith = function(str) { return (this.match(str+"$")==str) }

    var originalURL = "{!$Site.OriginalUrl}";
    var targetID = '';
    var action = 'view';
    
    if (originalURL.startsWith('/portal/apex/')) targetID = originalURL.substr(13,15); 
    if (originalURL.startsWith('/apex/')) targetID = originalURL.substr(6,15); 
    if (originalURL.startsWith('/portal/')) targetID = originalURL.substr(8,15); 
    if (originalURL.endsWith('/e')) action = 'edit';

    // Redirect to the Participant EDIT page 
    if (originalURL.startsWith('/portal/a1CQ') || originalURL.startsWith('/portal/a185'))
        window.location.href = '/portal/apex/Portal_Participant_Entry?ID=' + targetID;

    // Redirect to the State VIEW page 
    if (originalURL.startsWith('/portal/a19Q') || originalURL.startsWith('/portal/a1B5'))
        window.location.href = '/portal/apex/Portal_MyState';

    // Redirect to the Workshop VIEW page 
    if (originalURL.startsWith('/portal/a1BQ') || originalURL.startsWith('/portal/a195'))
        window.location.href = '/portal/apex/Portal_Workshop?id=' + targetID;

</script>

<!-- The rest of the page is from the standard FileNotFound visualforce page -->
  <apex:composition template="{!$Site.Template}">
    <apex:define name="body">  
      <center>
        <apex:panelGrid bgcolor="white" columns="1"> 
          <br/>
          <br/>
          <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" styleClass="topPanelContainer"> 
            <br/>
            <apex:outputPanel layout="block" styleClass="topPanel">
              <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="3"> 
                <apex:image value="{!$Resource.PortalLogo}" style="align: center;" />
                <apex:panelGroup >
                  <apex:outputText styleClass="title" value="{!$Label.site.page_not_found_detail}">      
                   <apex:param value="{!$Site.OriginalUrl}"/>
                  </apex:outputText>
                  <br/>
                  <br/>
                  <apex:outputText value="{!$Label.site.stay_tuned}"/>
                  <apex:outputText escape="false" value=" {!$Label.site.get_in_touch}">
                   <apex:param value="mailto:{!$Site.AdminEmailAddress}"/>
                   <apex:param value="{!$Label.site.email_us}"/>
                  </apex:outputText>
                </apex:panelGroup>
              </apex:panelGrid> 
             </apex:outputPanel>
          </apex:panelGrid> 
          <br/>
          <apex:messages />
          <br/>
        </apex:panelGrid>
      </center>
    </apex:define>
  </apex:composition>
</apex:page>

 

 

 

 

Best Regards,

 

Mike

Rich PRich P

I was having the same problem and this worked for me. Thanks!

BulentBulent

we will look in to this. It should work without the workaround

 

 

Rich PRich P

Thanks. In my case, I have a custom object with an overridden edit button linking to a visualforce page. As Mike said, it works for regular users, but not on the Customer Portal. I used the following modification of Mike's example to get it working:

 

    if (originalURL.startsWith('/invest2010/')) targetID = originalURL.substr(12,15); 
    if (originalURL.endsWith('/e')) action = 'edit';

    if (originalURL.startsWith('/invest2010/a01Q') || originalURL.startsWith('/invest2010/a018'))
        window.location.href = '/invest2010/apex/ApplicationEvaluation?id=' + targetID;

 

I will be happy to share further access to our code if you have any questions.

 

Regards,

Rich

BulentBulent

We have logged a bug for this and working on it. You shouldn't need to do any workaround it should just work if you overwrite the buttons with a visualforce pages.