• megsuma
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies

Hi all,

 

 I have a bit of a problem that probably shouldn't be a problem...I'm trying to do something that should be alot easier than it has been so far:

 

 I have a field being populated by a formula and the field is either a 1 or a 0 depending on the outcome of the formula. All I want is for a picklist to change value when the field's value changes.

 

Here is my trigger:

 

trigger CompanyGoalUpdate on Company_Goal__c (after insert, after update) {
	Company_Goal__c cmp = [SELECT Upcoming_Goal__c, Use_on_Company__c, LastModifiedDate FROM Company_Goal__c WHERE Id =: trigger.new[0].Id];
	
	if(cmp.Upcoming_Goal__c == 1)
		cmp.Use_on_Company__c = 'Use';
	else
		cmp.Use_on_Company__c = 'Do Not Use';
	
	DateTime RightNow = System.now();
	
	if(cmp.LastModifiedDate < RightNow.addMinutes(-30))
		update cmp;
}

 

Any thoughts?

 

Is it possible to pass a parameter to an Apex page without the user having to perform an action (such as clicking a button or link)? Essentially, the idea would be to have a VF page that takes a parameter from the query string and passes it to the apex controller when my getter function is called. Page is something like this:

 

<apex:page controller="CompanyStatsDashboardController"> ...Some javascript to get the query string parameter... <apex:image url="{!UserCountChart}"></apex:image> </apex:page>

 The reason I can't just call something like System().currentPageReference().getParameters().get() is because the VF page lives on a Dashboard, and as such renders in an iFrame. The iFrame has it's own URL that does not contain the parameter, and as far as I can tell you can't tell the Dashboard to pass parameters to the VF page. I've also tried setting an <apex:param> with the value I want to pass and using apexPages().currentPage().getParameters(), but this doesn't work either. 

 

 


Hi all, I've been programming in Apex/VisualForce for the past couple of weeks, just getting used to everything, and I've hit a bit of a roadblock.


I'm trying to generate a Google Chart from company statistics that we track and aggregate into reports and dashboards. On the particular dashboard is a very simple VisualForce page.



I'm putting some code in here, but the server continually times out when I hit Preview so I apologize if it doesn't look too good below.



I have this visualforce page:



<apex:page controller="MyStatsController" action="{!MyStatsController}">

<apex:image url="{!ReturnedURLFromController}"></apex:image>

</apex:page>





Next is my controller:




public class MyStatsController {

   String ReturnedURLFromController;

   List data;



   public void MyStatsController()

   {

      String cid = System.currentPageReference().getParameters().get('cid');

      Data = [Select ... where company_id =: cid ];

      ...

      ReturnedURLFromController = GenerateChartURL();

   }



   public string GenerateChartURL(){

      //Works on data to make the google chart url

      return chart_url;

   }

 }





This is my problem line:



String cid = System.currentPageReference().getParameters().get('cid');



When I open the Dashboard page from a custom link, the url resembles this:
https://na2.salesforce.com/01C50000000Bds1?cid=someCompanyId

 

But no matter what I do, my controller is finding cid as null. I have a check after cid gets assigned and if its still NULL after the getParameter().get()  call, it loads bogus data and changes the chart's title to a warning message, and this is what I get everytime.

 

If anyone can point me in the right direction here, I would really appreciate it.