You need to sign in to do that
Don't have an account?
Paul Ginther
Show static message in VF page based on field value
Based on the value of a picklist field I need to render a static message in a small VF page at the top of the record in Classic UI. I have created an Apex controller as well as the VF page, but I have not been able to make this work. I am new to this level of development so any assistance you might be able to give would be greatly appreciated. Basically, if a picklist field called Frequency contains one of three different values, I want to display a static text message. Below is the code I have written so far:
Apex Class – “ContentMessageInlineCtrl”
public with sharing class ContentMessageInlineCtrl {
public Content__c cov {get;set;}
public ContentMessageInlineCtrl(ApexPages.StandardController controller) {
if(!Test.isRunningTest()) {
controller.addFields(new List<String>{'Frequency__c'});
}
cov = (Content__c) controller.getRecord();
}
}
VisualForce Page = “ContentMessageInline”
<apex:page standardController="Content__c" extensions="ContentMessageInlineCtrl">
<style type="text/css">
.redAlert {
font-weight: bold;
color: #FF0000;
font-size : 22px;
text-decoration: none;
}
</style>
<apex:form >
<apex:outputPanel rendered="{if(!(Frequency__c == “Weekly”||Frequency__c == “Semi Monthly (Twice a month)”||
Frequency__c == “Bi Weekly (Every Other week)”)true,false)}">
<center>
<apex:outputText styleClass="redAlert" value="THIS IS WHERE THE STATIC MESSAGE WILL RESIDE"/> <br/>
</center>
</apex:outputPanel>
</apex:form>
</apex:page>
Apex Class – “ContentMessageInlineCtrl”
public with sharing class ContentMessageInlineCtrl {
public Content__c cov {get;set;}
public ContentMessageInlineCtrl(ApexPages.StandardController controller) {
if(!Test.isRunningTest()) {
controller.addFields(new List<String>{'Frequency__c'});
}
cov = (Content__c) controller.getRecord();
}
}
VisualForce Page = “ContentMessageInline”
<apex:page standardController="Content__c" extensions="ContentMessageInlineCtrl">
<style type="text/css">
.redAlert {
font-weight: bold;
color: #FF0000;
font-size : 22px;
text-decoration: none;
}
</style>
<apex:form >
<apex:outputPanel rendered="{if(!(Frequency__c == “Weekly”||Frequency__c == “Semi Monthly (Twice a month)”||
Frequency__c == “Bi Weekly (Every Other week)”)true,false)}">
<center>
<apex:outputText styleClass="redAlert" value="THIS IS WHERE THE STATIC MESSAGE WILL RESIDE"/> <br/>
</center>
</apex:outputPanel>
</apex:form>
</apex:page>
I have made little changes in VF page and controller (how outputPanel renders and how controller can set dynamic values for you based on the picklist value) and it should work for you now.
Thanks,
R
All Answers
I have made little changes in VF page and controller (how outputPanel renders and how controller can set dynamic values for you based on the picklist value) and it should work for you now.
Thanks,
R