You need to sign in to do that
Don't have an account?

Radio button to select an Opportunity Product from a list on a VF Page
Hi,
I am trying to develop a VF page Using Standard Controller as Opportunity. I want to display all the opportunity Products on the VF page along with radio buttons. User should be able to select only one opportunity product and the id of that line item has to be stored in an hidden field. How can I achieve that in Visual Force?
Thank You Inadvance for your help!!
I am trying to develop a VF page Using Standard Controller as Opportunity. I want to display all the opportunity Products on the VF page along with radio buttons. User should be able to select only one opportunity product and the id of that line item has to be stored in an hidden field. How can I achieve that in Visual Force?
Thank You Inadvance for your help!!
see Below example for your requirement,
Visualforce Page:
<apex:page standardController="Opportunity" extensions="extOpportunityProduct">
<script>
function setOppProduct(prId){
document.getElementById('{!$Component.frm.pbMain.hdnOppProduct}').value = prId;
}
</script>
<apex:form id="frm">
<apex:pageBlock id="pbMain">
<apex:inputhidden id="hdnOppProduct" value="{!strhdnOppProduct}"/>
<apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli">
<apex:column headerValue="Select">
<input type="radio" name="Productitem" value="{!oli.id}" onchange="setOppProduct('{!oli.id}');"/>
</apex:column>
<apex:column>
<apex:outputLabel value="{!oli.Opportunity.Name}"></apex:outputLabel>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
Public class extOpportunityProduct{
Public string strhdnOppProduct {get; set;}
Public extOpportunityProduct(apexpages.standardcontroller con){
}
}
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
All Answers
see Below example for your requirement,
Visualforce Page:
<apex:page standardController="Opportunity" extensions="extOpportunityProduct">
<script>
function setOppProduct(prId){
document.getElementById('{!$Component.frm.pbMain.hdnOppProduct}').value = prId;
}
</script>
<apex:form id="frm">
<apex:pageBlock id="pbMain">
<apex:inputhidden id="hdnOppProduct" value="{!strhdnOppProduct}"/>
<apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli">
<apex:column headerValue="Select">
<input type="radio" name="Productitem" value="{!oli.id}" onchange="setOppProduct('{!oli.id}');"/>
</apex:column>
<apex:column>
<apex:outputLabel value="{!oli.Opportunity.Name}"></apex:outputLabel>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
Public class extOpportunityProduct{
Public string strhdnOppProduct {get; set;}
Public extOpportunityProduct(apexpages.standardcontroller con){
}
}
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
This worked. Thank you so much.
My requirement is this: Create a Case from an Opportunity and add the related Opportunity Line Items to the Case related list or page layout. The Opportuntiy can be changed, add / remove Opportunity Line Items but not the Case Opportunity Products. Another Case can than be created with the updated Opportunity Line Items.
Thanks!