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
Charles McDowellCharles McDowell 

How to get the value of inputfield in standard controller extension

I am trying to get the value of the parent Record to redirect my child record back to the parent.   Parent is Quote__c and Child is QuoteDetail__c. I get a null for qID.  Can someone tell me what I am doing wrong?


<apex:page standardController="QuoteDetail__c" extensions="QuoteDetailRecExtension" sidebar="False" >{
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection columns="1">
                <apex:outputField value="{!QuoteDetail__c.Product__c}" />
                <apex:outputField value="{!QuoteDetail__c.Product_Category__c}" />
                <apex:outputField value="{!QuoteDetail__c.Order_In_System__c}" />
                <apex:outputField value="{!QuoteDetail__c.Quantity__c}"  />
                <apex:outputField value="{!QuoteDetail__c.Coverage_Density__c}" />
                <apex:outputField value="{!QuoteDetail__c.Product_Total__c}" />
                <apex:outputField value="{!QuoteDetail__c.Quote__c}" id="Quote"/>
                <apex:outputField value="{!QuoteDetail__c.ID}" rendered="false" />
            
            </apex:pageBlockSection>
            
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!qp}" var="q" >
                    <apex:column headerValue="Product/Size" value="{!q.ProductSizePrice__c}" />
                    <apex:column value="{!q.Quantity__c}" />
                    <apex:column value="{!q.List_Price__c}" />
                    <apex:column value="{!q.Ext__c}" />
                
                </apex:pageBlockTable>
            
            
            </apex:pageBlockSection>
        
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton value="Edit" action="{!Edit}"/ >
                <apex:commandButton value="Back" action="{!Back}" >
                        <apex:param name="Quote" value="{!QuoteDetail__c.Quote__c}" />
                </apex:commandButton>
            </apex:pageBlockButtons>

        </apex:pageBlock>
    
    </apex:form>
</apex:page>

public class QuoteDetailRecExtension {
    Public List<QuotePrice__c> qp {Get;Set;}
                               
    
    Public QuoteDetailRecExtension(Apexpages.StandardController cext) {
       String ID = apexpages.currentPage().getParameters().get('id');
        qp = [Select ProductSizePrice__c, Quantity__c, List_Price__c, Ext__c 
              From QuotePrice__c Where QuoteDetail__c = : Id];
    }
   

    Public pagereference back(){
       // Get the ParentID - QuoteID
        String qID = apexpages.currentPage().getparameters().get('Quote');
        
        system.debug('Quote ID = ' + qID);
        pagereference ret = page.QuoteDetail;
        ret.getParameters().put('ID', qID);
        ret.setRedirect(True);
        
        return ret;
    }
   
}
 
Waqar Hussain SFWaqar Hussain SF
Try below code snippet 
Public pagereference back(){
       // Get the ParentID - QuoteID
        String qID = apexpages.currentPage().getparameters().get('Id');
        
        system.debug('Quote ID = ' + qID);
        pagereference ret = page.QuoteDetail;
        ret.getParameters().put('ID', qID);
        ret.setRedirect(True);
        
        return ret;
    }



 
Charles McDowellCharles McDowell
Thanks, Waqar but
get('id') gives me the QuoteDetailID which is the child ID.   I need the Quote ID which is the parent
Waqar Hussain SFWaqar Hussain SF
try below code 
public class QuoteDetailRecExtension {
    Public List<QuotePrice__c> qp {Get;Set;}
	public string quoteId {get; set;}
                               
    
    Public QuoteDetailRecExtension(Apexpages.StandardController cext) {
       String ID = apexpages.currentPage().getParameters().get('id');
	cext.getId();
	quoteId = [Select Quote__c from QuoteDetail__c  where Id = : ID limit 1].Quote__c;
        qp = [Select ProductSizePrice__c, Quantity__c, List_Price__c, Ext__c 
              From QuotePrice__c Where QuoteDetail__c = : Id];
    }
   

    Public pagereference back(){
       // Get the ParentID - QuoteID
        
        system.debug('Quote ID = ' + quoteId );
        pagereference ret = page.QuoteDetail;
        ret.getParameters().put('ID', quoteId );
        ret.setRedirect(True);
        
        return ret;
    }
   
}

 
Charles McDowellCharles McDowell
I get the quoteDetailID and the Query the QuoteDetail to get the Quote ID.  Seems like a round about way to get a value that is on the screen

Thansk