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
coppelcoppel 

Visualforce Dashboard Component

Has anyone come across this issue, I have created a VisualForce page that I am displaying on a dashboard as a component.  Normal functionality for a dashboard component allows you to click to drill down.  This isn't the case with a visualforce dashboard component.  So to work around this I created a command button called details that when clicked redirects to my drill down report.  As an administrator this seems to be working perfectly.  You click on the details button and it opens the report in a full window.  As a non-administrator it is working differently.  When they click on the details button it is opening up the report but in the size of the dashboard component instead of a full window.  I don't understand why the functionality differs between users.  I would love your comments or work arounds.  Below is my code.

 

<apex:page controller="retrieveASNAccounts"> <apex:form > <apex:commandButton action="{!detail}" value="Details"/> <apex:pageBlock > <apex:pageBlockTable value="{!accounts}" var="a"> <apex:column value="{!a.name}"/> <apex:column dir="" value="{!a.First_ASN_Date__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page> ______________________________________________________________________ public class retrieveASNAccounts { public List<Account> getAccounts() { return [SELECT Name, First_ASN_Date__c FROM Account WHERE Account.ownerId =: userInfo.getUserId()AND First_ASN_Date__c != null order by First_ASN_Date__c DESC limit 10]; } public PageReference detail() { PageReference details = new PageReference('https://na5.salesforce.com/00O70000002ZGDl'); details.setRedirect(true); return details; } }

 

Best Answer chosen by Admin (Salesforce Developers) 
Scott JorgensenScott Jorgensen

It is strange that the behavior is different for the two users.  But, to me the behavior for the regular user seems correct and for the admin it seems unusual.

 

Here's what I would do to address it (note, this was not checked for typos):

 

 

<apex:page controller="retrieveASNAccounts">

<apex:form >

 

<a target="_top" href="{!detail}">Details</a>

 

<apex:pageBlock >

<apex:pageBlockTable value="{!accounts}" var="a">

<apex:column value="{!a.name}"/>

<apex:column dir="" value="{!a.First_ASN_Date__c}"/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>

______________________________________________________________________

 

public class retrieveASNAccounts {

public List<Account> getAccounts() {

return [SELECT Name, First_ASN_Date__c FROM Account WHERE Account.ownerId =: userInfo.getUserId()AND First_ASN_Date__c != null order by First_ASN_Date__c DESC limit 10];

}

 

public String getDetail() {

return 'https://na5.salesforce.com/00O70000002ZGDl';

}

}

 

 

 

Message Edited by Scott Jorgensen on 07-10-2009 04:08 PM
Message Edited by Scott Jorgensen on 07-10-2009 04:09 PM

All Answers

Scott JorgensenScott Jorgensen

It is strange that the behavior is different for the two users.  But, to me the behavior for the regular user seems correct and for the admin it seems unusual.

 

Here's what I would do to address it (note, this was not checked for typos):

 

 

<apex:page controller="retrieveASNAccounts">

<apex:form >

 

<a target="_top" href="{!detail}">Details</a>

 

<apex:pageBlock >

<apex:pageBlockTable value="{!accounts}" var="a">

<apex:column value="{!a.name}"/>

<apex:column dir="" value="{!a.First_ASN_Date__c}"/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>

______________________________________________________________________

 

public class retrieveASNAccounts {

public List<Account> getAccounts() {

return [SELECT Name, First_ASN_Date__c FROM Account WHERE Account.ownerId =: userInfo.getUserId()AND First_ASN_Date__c != null order by First_ASN_Date__c DESC limit 10];

}

 

public String getDetail() {

return 'https://na5.salesforce.com/00O70000002ZGDl';

}

}

 

 

 

Message Edited by Scott Jorgensen on 07-10-2009 04:08 PM
Message Edited by Scott Jorgensen on 07-10-2009 04:09 PM
This was selected as the best answer
coppelcoppel
Hi Scott, thank you for your assistance.  What you sent me is working in my sandbox but unfortunately I haven't been able to update my file in my production org because I don't have the proper test code written.  I am new to this and have been unable to figure out how to write the test code.  Are you able to provide any assitance?  I am not even sure what type of test code to use; method or class, testMethod or @isTest, Test.startTest and Test.stopTest.  Any help is greatly appreciated.
Scott JorgensenScott Jorgensen

Your Apex is minimal.  Writing your test method should take about 10 minutes or less.

 

Here's a nice article on how to get started with Apex testing:

 

 http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods

 

  

coppelcoppel

Hello Scott or anyone else who might be able to help.  I am writing my test code for proper coverage but running into some difficulties.  It might just be that I don't totally understand this process and how to use Eclipse.

 

My code that needs modification is currently in my production environment however it has no test code at all.  I am writing the test code in Eclipse.  If I run tests it is telling me in the code coverage results that line 10 isn't covered however I only have 9 lines in that class.  It is also telling me I don't have code coverage on lines that are commented out.  Is it running the test against the file that is in production or the file that I am working on in Eclipse?  How am I ever to get proper code coverage on my production code if the Apex Test Runner is running against the production code and not my locally saved file.

 

Here is my current code...

 

 

public class retrieveASNAccounts { public List<Account> getAccounts() { return [SELECT Name, First_ASN_Date__c FROM Account WHERE Account.ownerId =: userInfo.getUserId()AND Sales_Cockpit_Opt_Out__c = False AND First_ASN_Date__c != null order by First_ASN_Date__c DESC limit 10]; } //public String getDetail() { // return 'https://na5.salesforce.com/00O70000002ZGDl'; //} }

 

 

@isTest private class TESTretrieveASNAccounts { // private retrieveASNAccounts raa; // public TESTretrieveASNAccounts() { // retrieveASNAccounts raa = new retrieveASNAccounts(); // } static testMethod void getAccounts(){ /* System.debug([SELECT Name, First_ASN_Date__c FROM Account WHERE Account.ownerId =: userInfo.getUserId()AND Sales_Cockpit_Opt_Out__c = False AND First_ASN_Date__c != null order by First_ASN_Date__c DESC limit 10]); */ retrieveASNAccounts raa = new retrieveASNAccounts(); List<Account> testAccounts = raa.getAccounts(); System.debug( testAccounts ); } //static testMethod void getDetail(){ //retrieveASNAccounts raa2 = new retrieveASNAccounts(); //System.debug( raa2.getDetail() ); //} }

 

<apex:page controller="retrieveASNAccounts"> <apex:form > <!--a target="_top" href="{!detail}">Details</a--> <a target="_top" href="https://na5.salesforce.com/00O70000002ZGDl">Details</a> <apex:pageBlock > <apex:pageBlockTable value="{!accounts}" var="a"> <apex:column value="{!a.name}"/> <apex:column dir="" value="{!a.First_ASN_Date__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 Please assist!

 

Thanks,

 

Christian

 

Scott JorgensenScott Jorgensen

You need to use your Sandbox.

 

 

1) Create a Sandbox
2) It will have all your code from production
3) Create a new project in Eclipse using your Sandbox credentials (me@corp.com.<sandbox_name>)
4) Write your tests
5) When your tests pass in Sandbox then you're ready to deploy to production
6) Use the "Deploy to Server" feature of Eclipse to deploy your code to production (me@corp.com). 

 

Message Edited by Scott Jorgensen on 07-30-2009 08:15 PM
Message Edited by Scott Jorgensen on 07-30-2009 08:15 PM
coppelcoppel

Hi Scott,

 

I have been trying to follow your instructions but ran into a roadblock in the form of package.xml.  Is this file supposed to be auto generated or do I need to learn how to code this page so that all of my components show up thus avoiding erroring out when pushing to my sandbox?

 

Thanks,

 

Christian

Scott JorgensenScott Jorgensen

The file called "Package.xml" is generated when you create a Force.com project in Eclipse.  You can edit it by hand but I never do.  

 

Instead, it is easier to use the visual tool for selecting project components to be added or removed.  Check out the summary under "Project Synchronization" on this page: 

 

http://wiki.developerforce.com/index.php/An_Introduction_to_Force_IDE

 

 

Note: when you "Deploy to Server" in the steps described in my earlier comment... do not select package.xml to be deployed. 

Message Edited by Scott Jorgensen on 07-30-2009 08:21 PM