You need to sign in to do that
Don't have an account?
Laura Keeton
Obtain Account ID using ApexPages getparameters
I'm a newbie to Salesforce and Apex. I have a requirement to create a dynamic banner for Account pages based on criteria from another object where the options are entered by the user. So I'm adding a new visualforce page (which will be the banner) to the Account object. I'm can't seem to retrieve the current account ID from the account page.
Visualforce:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
text-align:center;
font-weight:bold;
font-size:150%;
padding:17px;
width:80%;
height:80x;
}
</style>
<apex:repeat value="{!lstPB}" var="pb" >
<apex:repeat value="{!acct}" var="a" >
<div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
<apex:outputPanel >
<apex:outputText value="{!a.Industry}"></apex:outputText><br/>
<apex:outputText value="{!a.Phone}"></apex:outputText><br/>
<apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
<apex:outputText value="{!a.Id}"></apex:outputText>
</apex:outputPanel>
</div>
</apex:repeat>
</apex:repeat>
</apex:page>
Apex:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
text-align:center;
font-weight:bold;
font-size:150%;
padding:17px;
width:80%;
height:80x;
}
</style>
<apex:repeat value="{!lstPB}" var="pb" >
<apex:repeat value="{!acct}" var="a" >
<div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
<apex:outputPanel >
<apex:outputText value="{!a.Industry}"></apex:outputText><br/>
<apex:outputText value="{!a.Phone}"></apex:outputText><br/>
<apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
<apex:outputText value="{!a.Id}"></apex:outputText>
</apex:outputPanel>
</div>
</apex:repeat>
</apex:repeat>
</apex:page>
Visualforce:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
text-align:center;
font-weight:bold;
font-size:150%;
padding:17px;
width:80%;
height:80x;
}
</style>
<apex:repeat value="{!lstPB}" var="pb" >
<apex:repeat value="{!acct}" var="a" >
<div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
<apex:outputPanel >
<apex:outputText value="{!a.Industry}"></apex:outputText><br/>
<apex:outputText value="{!a.Phone}"></apex:outputText><br/>
<apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
<apex:outputText value="{!a.Id}"></apex:outputText>
</apex:outputPanel>
</div>
</apex:repeat>
</apex:repeat>
</apex:page>
Apex:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
text-align:center;
font-weight:bold;
font-size:150%;
padding:17px;
width:80%;
height:80x;
}
</style>
<apex:repeat value="{!lstPB}" var="pb" >
<apex:repeat value="{!acct}" var="a" >
<div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
<apex:outputPanel >
<apex:outputText value="{!a.Industry}"></apex:outputText><br/>
<apex:outputText value="{!a.Phone}"></apex:outputText><br/>
<apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
<apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
<apex:outputText value="{!a.Id}"></apex:outputText>
</apex:outputPanel>
</div>
</apex:repeat>
</apex:repeat>
</apex:page>
Anyway, there is a better way to get the Id then using ApexPages' getParameters method.
You can get the Id from the standard controller passed in to the controller externsion's constructor.
For example: