I'm experimenting with the code below from another post on stackexchange:
All I'm trying to do is display a VF box in Opportunities to instruct Users on what to do at each stage. It uses a custom object, controller and a VF page. The custom object holds 2 fields, one for the stage and another for the instructions. I have made a few changes, but nothing major. For some reason, when I test the VF page I get the following error:
Content cannot be displayed: Attempt to de-reference a null object
I have created new records in the custom object that match the stage names in the opportunity object.
Can anyone help?
Controller Code:
public class OppInstructionsController {
public Opportunity opp {get;set;}
public list<Opportunity_Helper__c> myRules {get;set;}
public map<string,string> stage2Instructions {get;set;}
public string StageInstructions {get;set;}
public OppInstructionsController(ApexPages.StandardController controller){
this.opp= (Opportunity)controller.getRecord();
myRules = [Select Id, StageName__c, Instructions__c From Opportunity_Helper__c];
for(Opportunity_Helper__c rule : myRules){
stage2Instructions.put(rule.StageName__c, rule.Instructions__c);
}
StageInstructions = stage2Instructions.get(this.opp.StageName);
}
}
VF Page:
<apex:page StandardController="Opportunity" extensions="OppInstructionsController">
<apex:outputText value="{!StageInstructions}"/>
</apex:page>