If you get this error while working with a Visualforce page in Salesforce the reason could be that you are trying to call a method that doesn’t exists in the action attribute of the apex:page tag. I.e. in this case ‘aMethod’ does not exist in class ‘controllerClass’.
<apex:page title="A Title" standardController="Opportunity"
extensions="controllerClass" tabStyle="Opportunity" showheader="true"
sidebar="true" action="{!aMethod}" >
Here is an example of
1) how to query fields of an object and fields on records of a related object
2) how to loop over the queried records and the records of the related object in Apex
In the below example the Opportunity is the master of a master-detail relationship where Sub_Object__c is the detail. The task is to query fields and set these to values on both the opportunity and to the related Sub_Object__c records.
public void resetStates() {
// Create map of a list of opportunities.
Map theMap = getTheMap();
// List all opportunities except the selected one,
// i.e. the map excludes the selected opp.
List allOpps = [SELECT Id, Selected__c,
(SELECT id, Selected__c FROM Sub_Object__r) FROM Opportunity
WHERE Id IN: theMap.keySet()];
// Loop over the opportunities and set values
for (Opportunity o : allOpps) {
o.Selected__c = false;
// Loop over the records retrieved in the nested SELECT statement and set values
// Do this for each opportunity
for (Sub_Object__c so : o.Sub_Object__r) {
so.Selected__c = false;
}
}
// Update the db with the new values
update allOpps;
}
Tagged as:
apex,
salesforce,
soql
When a report is scheduled to run you can decide to email the results to yourself or to others.
First you choose to schedule the report. Assuming you are in edit mode of a report, press the button ‘Schedule Future Runs…’.

Now specify next to ‘Email Report’ if the report should be emailed to yourself or to more people. Choosing ‘To me and/or others…’ provides you with more options.

Now you can choose from public groups, roles, roles and subordinates and users. What is possible to choose from here is actually already determined by the access to the report folder where the report is located.
Edit the report folder and choose from the following settings.

The first option makes it possible to choose any email recipient in the report. The last option lets you limit the access a bit.
You are only able to select individual users as recipients of report emails if the folder that contains the report is accessible to All Users. If the Report folder is shared to a group you can only email to the group, not the individual users within the group.
Tagged as:
report,
report folder,
salesforce
We had the following situation recently:
A picklist (picklist 1) with two defined values A and B where value ‘A’ is set as default value.
Another picklist (picklist 2) just above this one have four values where none of them is set to default.
When I create a new Account which is the object that hold these two picklist fields, the default value for picklist 1 is value ‘A’ and for picklist 2 it is ‘-None-’.
Now, I would like to have both picklist default values to ‘-None-’. So I remove the default value from ‘A’ on picklist 1 and save. When I try to create an account now there is no change, still ‘A’ is the default value.
I managed to solve the problem by removing the field value ‘A’ on picklist1 and Save. And then create it again (not as default this time) and Save.
This made it work as wished for!
Tagged as:
default,
picklist,
salesforce
A user in our organization needed to clarify a few things about some report folders. Who created the folder and who modified it. He also wanted to find out things about a few reports that were hard to browse using the GUI.
I thought that the API would be good to use here but quickly found that the tools that I normally use, i.e. the Data Loader, Apex Explorer or Force.com Explorer didn’t have a representation for the Report object. A quick search on the net says that the report object is available in API-version 20.0 and later. Which means that if you are using the latest version of the force.com IDE for Eclipse you will be able to use this.
Now, regarding report folders. The GUI doesn’t offer much information about the folder. The API does though and if you are having trouble finding it (you might be looking for a Report Folder object for example), you should look for the Folder object. This object has a Type field with four different values; Document, Email Template, Report and Dashboard. So create your SOQL query against the Folder object and specify Type=’Report’ and you will get all the information you need.
Tagged as:
api,
folder,
report,
salesforce
Assume you are on an account record and pressing a button which opens up a Visualforce page on which you need the id of the account. In other words you need the referrer. But not the URL since you a are interested in the id. Below are two similar ways which both are getting the id from the query string.
Look at this part of the URL which you get when landing on the Visualforce page.

The marked area displays one way to get the account id. The lkid-parameter is the id of the account and can be extracted in Apex using:
ApexPages.currentPage().getParameters().get('CF00NM000000Tvr6_lkid');
Another part of the same URL reads like this:

The marked area displays another way. Read it like this: retURL = /001M0000005ULOd. So in this case the leading slash must be removed first. The id is extracted in Apex this way:
ApexPages.currentPage().getParameters().get('retURL').substring(1,16);
Tagged as:
apex,
referer,
salesforce
Usually when I deploy things from the Salesforce sandbox to production I choose some of the elements to deploy and that works well.
This time, I wanted to deploy all design elements, i.e. deploy everything that is deployable using the Force.IDE plugin for Eclipse for a Salesforce sandbox. I wanted to deploy from Test to Dev.
It takes quite some time and when it was done I got one failure saying:
package.xml : Bad manifest file:Invalid byte 2 of 3-byte UTF-8 sequence.
package.xml : No package.xml found

I found a fast fix to this here. Read here for a good explanation.
Basically what you need to to is to add a few parameters to the eclipse start-up command.
C:\eclipse\eclipse.exe -vmargs -Dfile.encoding=UTF-8

Restart Eclipse and try again and there should be no problem!
Tagged as:
deploy,
eclipse,
salesforce
When you want to create a button for an object you can override a standard or create a custom one. On the page for this you choose ‘Visualforce Page’ as content source. One thing you’ll discover is that there are no choices if there are also no Visualforce pages with a standard controller to the object of the button.

In this case I have created a Visualforce page with a standard controller to object ‘CObject_1__c’ and that is why this page is a choice in the content picklist. The following would be the first row of the VF page in this case:
<apex:page standardcontroller=”CObject_1__c”>
Tagged as:
controller,
salesforce,
visualforce
Today I attended the webinar Winter ’12 release preview to learn about what’s coming in Salesforce winter ’12 release. It was quite a few interesting things that I’m looking forward to trying out.
A very small but wished-for adjustment is to being able to make Setup the default landing page when logging into Salesforce.
Go to your user record:

Select the checkbox ‘Make Setup My Default Landing Page’:

When logging into Salesforce the Setup will open up straight away which is rather convenient if you are a developer or administrator. Notice the the Setup home page also has changed quite a bit:
Tagged as:
salesforce winter12
We use Salesforce together with BigMachines as our CRM-system and product configurator. This means very briefly that when our business are creating agreements they enter BigMachines from a Salesforce opportunity.
This procedure stopped working as it used to after this weekend’s upgrade to the Winter ’12 release of Salesforce sandboxes.
We get several errors. One of them is:
Invalid Session ID found in SessionHeader: Illegal Session
Another one that pops up sometimes is:
Stack Overflow
Another strange error that only my user seems to be affected by is a complaint about an integration and a SF field that most certainly works.
We don’t know how to handle this and both Salesforce and BigMachines are now involved in finding the issue. I have found similar threads on the Salesforce developer forums from 2008 after the upgrade to Winter ’08 but no obvious solution. See the Google results.
The problem is very annoying of course since I am having problems to actually work. And furthermore this really needs to be fixed by October 14th when production is being upgraded.
Anyone who got ideas are very welcome to post them here. When the problem is solved and if we get an explanation I will post it here as well.
Tagged as:
bigmachines,
integration,
release,
salesforce,
session,
winter12