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
Miller 95Miller 95 

Predefining IDs within VisualForce


I am creating a Visualforce email template and having a hard time using IDs within the code. My relatedto object is PricebookEntry, as shown:


Within the code I utilize the command {!relatedto.unitprice}. Once I send the email, it then ask me for the PricebookEntryID. I would like to have that ID predefined within the code so users do not have to have that ID on hand. So the code would related to/look something like:

{!relatedto.01uC000000ARO67IAH.unitprice} - I realize this is wrong, but providing an example of what I am explaining.

Any suggestions of how to predefine IDs within Visualforce so users only have to deal with selecting recipients?
In your controller, set a map<id,object> with a public get methods. something like this:
public class someController {

    public map<id, foo> AwesomeMap {get; private set;}

   public someController() {
      // initialize your map here.

Then in your vf code you can do soemthing like this


In short, use a map set in your controller for this. 

Also, why are you hard coding ids? thats a code smell.