You need to sign in to do that
Don't have an account?
Aam M
different values of picklist should display different lookup Fields
1. I want to display other lookup fields when i select different values from picklist "COST HEAD", If i select value as opportunity, Lookup field should displayed next to the "Select Opportunity" Field, similarly same should be displayed for "Select Campaign" & "Select Project", But How can i give only one lookup field & in that lookup i should select either opporunity, Campaign or project , How should i achieve this???
2. If I give Rerendered to form level it is working but , all mandatory fields are showing error before entering the data,
For example, without entering Expens Report ID, if i select Cost Head picklist it will show error on all mandatory fields...
How should overcome this problem..
Please help me with the code & refer the screenshot & Code!!
2. If I give Rerendered to form level it is working but , all mandatory fields are showing error before entering the data,
For example, without entering Expens Report ID, if i select Cost Head picklist it will show error on all mandatory fields...
How should overcome this problem..
Please help me with the code & refer the screenshot & Code!!
<apex:page standardController="Expense_Line_Item__c" extensions="SaveAndNew" sidebar="false" showHeader="true" > <style> span.dateFormat { display:none; } </style> <style> .text { font-family:Times New Roman ; font-size:13px; font-style:Bold; color:black;} .pbHeader{ color:#01375B; width:100%; font-size:200%; font-family:; } .pbsHeader1 color:#01375B; width:100%; font-size:200%; font-family;; } </style> <apex:slds /> <div class="slds-scope"> <apex:form id="TR"> <apex:pageBlock mode="mainDetail" tabStyle="Account" > <apex:facet name="header">Line Items</apex:facet> <apex:pageBlockSection columns="2" title=" " collapsible="false"> <apex:pageBlockSectionItem > <apex:outputLabel Value="Expense Report Id" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Expense__c}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Expense Line Item Description" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Name}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Date" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Date__c}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Bill Available" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Bill_Available__c}" /> </apex:pageBlockSectionItem> <!-- <apex:pageBlockSectionItem > <apex:outputLabel Value="Date" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Date__c}" style="width:150px;" /> </apex:pageBlockSectionItem>--> <!--<apex:pageBlockSectionItem > <apex:outputLabel Value="Expense Line Item Description" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Name}" style="width:150px;" /> </apex:pageBlockSectionItem>--> <apex:pageBlockSectionItem > <apex:outputLabel Value="Merchant" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Merchant__c}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value=" Merchant GST Number" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Merchant_GST_Number__c}" style="width:150px;"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection columns="2" title="Expense Details " collapsible="true"> <apex:pageBlockSectionItem > <apex:outputLabel Value="Approved" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Approved__c}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Amount" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Amount__c}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Payment Type" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Payment_Type__c}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Cost Head" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Cost_Head__c}" style="width:150px;" required="true" > <apex:actionSupport event="onchange" rerender="TR" /> </apex:inputField> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Select Campaign" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Related_to_Campaign__c}" style="width:150px;" rendered="{!IF( Expense_Line_Item__c.Cost_Head__c== 'Campaign',true,false )}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Select Opportunity" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Related_to_Opportunity__c}" style="width:150px;" rendered="{!IF( Expense_Line_Item__c.Cost_Head__c== 'Opportunity',true,false )}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Select Project" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Project__c}" style="width:150px;" rendered="{!IF( Expense_Line_Item__c.Cost_Head__c== 'Project',true,false )}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Expense Head" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Expense_Head__c}" style="width:150px;" required="true" > <apex:actionSupport event="onchange" rerender="TR" /> </apex:inputField> </apex:pageBlockSectionItem> <!-- <apex:outputPanel id="ren">--> <!-- </apex:outputPanel> --> <!-- <apex:pageBlockTable value="{!Expense_Line_Item__c}" var="item" columns="2" > <apex:column> <apex:outputLabel > <apex:inputField label="City" value="{!item.City__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" /></apex:outputLabel> <apex:inputField label="Mode of travel" value="{!item.Mode_Of_Travel__c}" rendered="{!IF(Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" /> <apex:inputField label="Location from" value="{!item.Location_From__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" /> <apex:inputField label="Location to" value="{!item.Location_To__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" /> </apex:column> <apex:column> <apex:inputField value="{!item.Sub_Expense__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Food',true,false )}" /> </apex:column> <apex:column> <apex:inputField value="{!item.Sub_Expense__c}" rendered="{!IF(Expense_Line_Item__c.Expense_Head__c== 'Entertainment',true,false )}" /> </apex:column> <apex:column> <apex:inputField value="{!item.Sub_Expense__c}" rendered="{!IF(Expense_Line_Item__c.Expense_Head__c== 'Lodging',true,false )}" /> </apex:column> <apex:column> <apex:inputField value="{!item.Sub_Expense__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Others',true,false )}" /> </apex:column> </apex:pageBlockTable>--> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c == 'Travel',true,false )}" > <apex:outputLabel Value="City" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.City__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" > <apex:outputLabel Value="Mode Of Travel" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Mode_Of_Travel__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" > <apex:outputLabel Value="Location From" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Location_From__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" > <apex:outputLabel Value="Location To" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Location_To__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Travel',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Food',true,false )}" > <apex:outputLabel Value="Sub Expense" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Sub_Expense__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Food',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Entertainment',true,false )}" > <apex:outputLabel Value="Sub Expense" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Sub_Expense__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Entertainment',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Lodging',true,false )}" > <apex:outputLabel Value="Sub Expense" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Sub_Expense__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Lodging',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Others',true,false)}" > <apex:outputLabel Value="Sub Expense" styleClass="text" /> <apex:inputField value="{!Expense_Line_Item__c.Sub_Expense__c}" rendered="{!IF( Expense_Line_Item__c.Expense_Head__c== 'Others',true,false )}" style="width:150px;" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel Value="Comments" styleClass="text" /> <apex:inputTextarea value="{!Expense_Line_Item__c.Comments__c}" style="width:150px;" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> <div align="center" draggable="false" > <apex:commandButton action="{!Save}" value="Save" style="font-style:BOld;size:20px;font-family:Georgia ;color:Black; background:LightBlue;width:95px;" /> <apex:commandButton action="{!Cancel}" value="Cancel" style="font-style:BOld;size:20px;font-family:Georgia ;color:Black; background:LightBlue;width:95px;" /> <apex:commandButton action="{!saveNew}" value="Save & New" style="font-style:BOld;size:20px;font-family:Georgia ;color:Black; background:LightBlue;width:95px;" /> </div> </apex:form> </div> </apex:page>
Instaed of using renederd can you please try some javascript function which shows and hide related field section.