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
SFDC@ErrorSFDC@Error 

Auto Populate look field value

Hi All 
How can i auto populate text field value when i will select lookup field.I have written a class for add/delete row.I am trying to implement same autopopulate funtinality,but not sure how to achieve that requirement.My lookup field is product__c ..
 
public with sharing class QuoteLineItemAddRow {
    
  
   public id challanid;
   public List<Quotation_Line_Item__c>   Md{get;set;}
   

    public QuoteLineItemAddRow(ApexPages.StandardController controller) {

     
     challanid=Apexpages.currentPage().getParameters().get('qid');
           Md=new list<Quotation_Line_Item__c>(); 
           Quotation_Line_Item__c m=new Quotation_Line_Item__c();
           m.Quote_Name__c=challanid;
           Md.add(m);
           
           
    }
    
   
   
public void addrow()
    {
        Quotation_Line_Item__c m=new Quotation_Line_Item__c();
           m.Quote_Name__c=challanid;
           Md.add(m);
               }
               
               public void removerow()
    {
    Integer i = Md.size(); 
 Md.remove(i-1);
    }
    
     public pagereference save() 
    {
    insert Md;
    PageReference home = new PageReference('/' + challanid + '?nooverride=1');
 home.setRedirect(true);
 return home;
    }
    public pagereference cancel()
    {
    PageReference home = new PageReference('/' + challanid + '?nooverride=1');
 home.setRedirect(true);
 return home;
    }
}
 
<apex:page standardController="Quote__c" extensions="QuoteLineItemAddRow" lightningStylesheets="true" showHeader="false" sidebar="false">
<apex:slds />
<div >
<apex:form >
<apex:pageblock title="">
<apex:pageblockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageblockButtons>


<div style="width:800px;">
<apex:pageblockTable value="{!Md}" var="c" id="table">
<!---<apex:column headerValue="Quote Name"> 
<apex:inputField value="{!c.Quote_Name__c}"/> 
</apex:column>--->
<apex:column headerValue="Product Name">
 <apex:inputField value="{!c.Product__c}"> 
</apex:inputField>
</apex:column>
<apex:column headerValue="Size">
 <apex:inputField value="{!c.Size__c}"/> 
</apex:column>
<apex:column headerValue="Price">
 <apex:inputField value="{!c.Product__r.Basic_Unit_Price__c}"/> 
</apex:column>
<apex:column headerValue="Quantity">
 <apex:inputField value="{!c.Qutantity__c}"/> 
</apex:column>
</apex:pageblockTable>
</div>


<apex:pageblockButtons location="bottom">
 <div style="text-align:right;margin-right:30px;font-weight:bold;"> 
<apex:commandLink value="Add Row" action="{!addRow}" rerender="table" immediate="true" /> 
&nbsp;|&nbsp;&nbsp; 
<apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table" immediate="true" />
 </div> </apex:pageblockButtons>
</apex:pageblock>
</apex:form>
</div>
</apex:page>

 
Alice SmithAlice Smith
Thanks for sharing the code. I am looking for this type of tool for my project (https://www.paisa.co/credit-card/fi/hdfc-bank). Really a great job. I hope this will work.