firstly we need to hide the fields first name and last name, when we choose lookup in gift card holder automatically it displays first name and last name and gift card holder name same as in first name and last name
public Boolean displayName {get; set;}
In the Constructor assign the value to true.
displayName = true;
public void populateName(){
Gift_Card_Holder__c gc = [Select Id, First_Name__c, Last_Name__c from Gift_Card_Holder__c where Id =: giftpurchase.Gift_Card_Holder__c];
giftcardholder.First_Name__c = gc.First_Name__c;
giftcardholder.Last_Name__c = gc.Last_Name__c;
displayName = false;
}
Please paste your existing code, so that it will be easy to help you.
For these kind of requirements, we have to use the <apex:actionSupport tab with reRender attribute.
Please look into the below link:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionSupport.htm
Please do let me know if it helps you.
Regards,
Mahesh
<apex:pageBlock >
<table width="25%" align="center">
<tr>
<td style="font-size:10pt;" align="right">Gift Card Holder: </td>
<td><apex:inputField value="{!giftpurchase.Gift_Card_Holder__c}" required="true"/></td>
</tr>
<tr>
<td style="font-size:10pt;" align="right">First Name: </td>
<td><apex:inputField value="{!giftcardholder.First_Name__c}" required="true"/></td>
</tr>
<tr>
<td style="font-size:10pt;" align="right" >last Name: </td>
<td><apex:inputField value="{!giftcardholder.Last_Name__c}" required="true"/></td>
</tr>
<tr>
<td style="font-size:10pt;" align="right">Purchasing Amount: </td>
<td><apex:inputField value="{!giftpurchase.Cost__c }" required="true" /></td>
</tr>
<tr>
<td style="font-size:10pt;" align="right">Gift Card Square Number: </td>
<td><apex:inputField value="{!giftpurchase.Gift_Card_Square_number__c }" required="true" /></td>
</tr>
<tr>
<td style="font-size:10pt;" align="right">Payment Confirmation Code: </td>
<td><apex:inputField value="{!giftpurchase.Payment_confirmation_code__c}" required="true" /></td>
</tr>
</table>
<br/><center><apex:commandButton value="Save" action="{!savegift}" /> <apex:commandButton value="Cancel" action="{!paymenbackpage}" Immediate="true"/></center><br/>
</apex:pageBlock>
Thanks
Dakshendra.R
Please find the below code:
Visualforce Page:
Part of controller:
Please do let me know if it helps you.
Regards,
Mahesh
Please find the below VF page:
Part of Controller Code:
Please do let me know if it helps you.
Regards,
Mahesh