How to retrieve and split the dropdown picklist values in Visualforce page Salesforce || How to separate multi values from Picklist dropdown value Using Apex method in Visualforce Page Salesforce || How to get the index number value of the list in VisualForce Salesforce

752 views


Hey guys, today in this post we are going to learn about How to retrieve and split the dropdown picklist values in Visualforce page Salesforce.

In this scenario, We will fetch the currency picklist value based on Quote Record Id and split from currency and it’s currency code uses of Apex class method in Visualforce. To know more details, Click Here.

 

Final Output →

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!

 

retrieve and split the dropdown picklist values in Visualforce -- w3web.net

 

You can download file directly from github by Click Here.

 

 

Other related post that would you like to learn in Salesforce

 

  • Find the below steps ▾

 

Create Visualforce Page

Step 1:- Create Visualforce Page : splitCurrencyVf.vfp

From Developer Console >> File >> New >> Visualforce Page

splitCurrencyVf.vfp [Visualforce Page]

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  1.    <apex:page standardController="Quote" extensions="splitCurrencyVfCtrl">
  2.     <div class="slds slds-p-around_small" style="padding:10px;">
  3.         <table width="50%" border="1" cellspacing="0" cellpadding="5" bordercolor="#ddd" class="slds-table slds-table_bordered slds-table_col-bordered" style="border-collapse:collapse;">
  4.             <tr>
  5.                 <th><strong style="color:#009ee6;">Quote Name</strong></th>              
  6.                 <th><strong style="color:#009ee6;">Line Item Currency</strong></th>                
  7.             </tr>    
  8.             <apex:repeat value="{!quoteObj}" var="qotItem">
  9.                 <tr> 
  10.                     <td><p><strong><apex:outputText value="{!qotItem.Name}"/></strong></p></td>
  11.                     <td>
  12.                         <apex:variable var="index" value="{!1}" />
  13.                         <table width="100%" border="1" cellspacing="0" cellpadding="5" bordercolor="#ddd" class="slds-table slds-table_bordered slds-table_col-bordered" style="border-collapse:collapse;">
  14.                             <apex:repeat value="{!qotItem.QuoteLineItems}" var="qLine" id="theRepeat">
  15.                                 <tr>
  16.                                     <td width="10%">1.{!index}.</td>
  17.                                     <td><apex:outputText value="{!qLine.Currency__c}"/></td>                                    
  18.                                     <apex:variable var="index" value="{!index + 1}" />
  19.                                 </tr>
  20.                             </apex:repeat>
  21.                         </table>  
  22.                     </td>
  23.                 </tr>   
  24.             </apex:repeat>
  25.  
  26.         </table>
  27.     </div>
  28. </apex:page>

 

Create Apex Class Extension Controller in Visualforce

Step 2:- Create Apex Class : splitCurrencyVfCtrl.apxc

From Developer Console >> File >> New >> Apex Class

splitCurrencyVfCtrl.apxc [Apex Class Controller]

  1.    public class splitCurrencyVfCtrl {   
  2.  
  3.     public String MstrId{GET;SET;}
  4.     public Quote quoteObj{GET;SET;}
  5.     public String curyCode{GET;SET;}
  6.     public String currName{GET;SET;}
  7.     public splitCurrencyVfCtrl(ApexPages.StandardController Controller){
  8.         //QuoteLineItems
  9.         MstrId = ApexPages.currentPage().getParameters().get('id');
  10.         quoteObj = [SELECT Id, Name, (SELECT Id, Currency__c FROM QuoteLineItems) FROM Quote WHERE Id=:MstrId ];
  11.  
  12.         INTEGER childSize;
  13.  
  14.         system.debug('qItm# ' + quoteObj.QuoteLineItems);
  15.  
  16.  
  17.            FOR(QuoteLineItem qItm:quoteObj.QuoteLineItems){   
  18.  
  19.                IF(qItm.Currency__c !=NULL ){
  20.                     curyCode = qItm.Currency__c.split('-').get(1);
  21.                     qItm.Currency__c =curyCode;
  22.                     system.debug('curyCode## ' + curyCode);
  23.                 }  
  24.  
  25.  
  26.            }
  27.  
  28.             childSize = quoteObj.QuoteLineItems.size();
  29.             system.debug('childSize ' + quoteObj.QuoteLineItems.size());
  30.  
  31.     }    
  32.  
  33. }

 

 

 
split the dropdown picklist values in Visualforce -- w3web.net
  
retrieve and split the dropdown picklist values in Visualforce -- w3web.net

Further post that would you like to learn in Salesforce

 


 

 

How do I split a multi select picklist value in Salesforce?

Multi select picklist values are stored semi colon seperated in database. So you can split them by semi colon ' ; ' to get seperated values.

What is split () used for?

The split() function can be used to split a given string or a line by specifying one of the substrings of the given string as the delimiter.

How to get the values from the visualforce page to controller?

In the VF page we have used param at two places, one in the commandbutton and the other in actionfunction. The param which is in the command button has a value specified to it and also assigned to a variable in controller. This value will be passed to the variable in the controller if the button is clicked.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses →

👉 Get Free Course →

📌 Salesforce Administrators

📌 Salesforce Lightning Flow Builder

📌 Salesforce Record Trigger Flow Builder

👉 Get Free Course →

📌 Aura Lightning Framework

📌 Lightning Web Component (LWC)

📌 Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment