3

I have a simple redirect link that goes through a visual force page that works perfectly fine except for non-administrative users the redirect url does not include the parameter it needs to build the report. I'm not aware of permission issues here so I'm not sure what the problem is here.

Have a formula field that builds a hyperlink like so:

HYPERLINK('/apex/VF_Page?Id=' + Main_Account_Id__c, 'Efforts')

Then the visual force page builds a new report URL passing the parameter from the controller:

<apex:page controller="ControllerAccountFieldsbyId" >
    <div style="margin: 10% auto; text-align: center;">
        <h4>Please wait while your report is being prepared...</h4><br/>
        <apex:image url="{!$Resource.Loading_Bar}" width="400" height="50"/>
        <script> window.top.location = window.location.protocol+"//"+window.location.host+'/00Od0000003jq9l?pv0={!account.Related_Accounts__c}'</script>
                                          ^ THIS IS THE REDIRECT URL                   REPORT ID ^                ^ MISSING PARAMETER FOR NON-ADMIN USER
    </div>
</apex:page>

This builds a URL like so:

https://na14.salesforce.com/{report_id}?pv0={**missing_id**}

Here is the controller class:

public with sharing class ControllerAccountFieldsbyId {
    public Account getAccount() {
        if(!string.isEmpty(ApexPages.currentPage().getParameters().get('Id'))){
            return [
                SELECT Id, ID__c, Main_Account_Id__c, Name, Related_Accounts__c FROM Account
                WHERE Id = :ApexPages.currentPage().getParameters().get('Id')];
        } else {
            return new Account();
        }
    }
}

Again this works just fine AS IS for admin users, the only issue is when a non-admin user clicks the link they are redirected without the account ID that is supplied from the controller.

3
  • How does your VF page URL look, paste the URL in your question. You have built your VF page on a custom controller, unless you explicitly mention /apex/vfpage?id='xxxxxxxxx' your ID is always going to return null and the users will see a blank value for related account.
    – Rao
    Commented Jun 2, 2015 at 23:27
  • I posted the VF url in the last line already... I'll edit to clarify Commented Jun 2, 2015 at 23:46
  • You posted the resulting url when you load the page formed through the js, I want to see the vf page url. It should be something like /apex/urpagename? Id=xxxx
    – Rao
    Commented Jun 3, 2015 at 3:29

2 Answers 2

2

I recommend to check field level security of your field for profile you are finding this missing .

I doubt that FLS for profile for field that's passed as parameter is not set to visible to cause this issue .

2
  • Thanks for pointing out the obvious, sometimes that's what we need ;) I kept thinking it was something with the VF page, didn't even cross my mind to check that field for some reason. Commented Jun 3, 2015 at 17:53
  • Glad it helped you mate :).. Commented Jun 3, 2015 at 18:23
0

Have you given access to that VF page to respective profiles who should be having access?

Go to Pages and for each VF page you will see security link, click on it and see who all had permissions. This is one important security control to consider.

3
  • Thanks for that, but yes, the User is under the "Support Reps" profile and that profile is enabled for the visual force page. Great suggestion though Commented Jun 3, 2015 at 0:56
  • You were using with sharing this means clearly one of the field must be missing with minimal permission. Simplest way to find that out is to run a Soql query with the respective user/profile and check if the results are returned as expected. It becomes easy to further fix the security.
    – DJD
    Commented Jun 3, 2015 at 2:47
  • I added "with Sharing" in attempt to follow permissions that are in place, if I go back to removing it nothing changes. Commented Jun 3, 2015 at 4:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .