Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retrieve and split the dropdown picklist values in Visualforce page Salesforce #8

Open
vijayk3327 opened this issue Sep 13, 2023 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@vijayk3327
Copy link
Owner

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.

👉 Get source code live demo link:-

Create Visualforce Page
Step 1:- Create Visualforce Page : splitCurrencyVf.vfp

`<apex:page standardController="Quote" extensions="splitCurrencyVfCtrl">







<apex:repeat value="{!quoteObj}" var="qotItem">




</apex:repeat>

    </table>
</div>

</apex:page>`

Create Apex Class Extension Controller in Visualforce
Step 2:- Create Apex Class : splitCurrencyVfCtrl.apxc

`public class splitCurrencyVfCtrl {

public String MstrId{GET;SET;}
public Quote quoteObj{GET;SET;}
public String curyCode{GET;SET;}
public String currName{GET;SET;}
public splitCurrencyVfCtrl(ApexPages.StandardController Controller){
    //QuoteLineItems
    MstrId = ApexPages.currentPage().getParameters().get('id');
    quoteObj = [SELECT Id, Name, (SELECT Id, Currency__c FROM QuoteLineItems) FROM Quote WHERE Id=:MstrId ];

    INTEGER childSize;

    system.debug('qItm# ' + quoteObj.QuoteLineItems);


       FOR(QuoteLineItem qItm:quoteObj.QuoteLineItems){   

           IF(qItm.Currency__c !=NULL ){
                curyCode = qItm.Currency__c.split('-').get(1);
                qItm.Currency__c =curyCode;
                system.debug('curyCode## ' + curyCode);
            }  


       }

        childSize = quoteObj.QuoteLineItems.size();
        system.debug('childSize ' + quoteObj.QuoteLineItems.size());

}    

}`

👉 Get source code live demo link:-

Quote Name Line Item Currency

<apex:outputText value="{!qotItem.Name}"/>


<apex:variable var="index" value="{!1}" />

<apex:repeat value="{!qotItem.QuoteLineItems}" var="qLine" id="theRepeat">



<apex:variable var="index" value="{!index + 1}" />

</apex:repeat>
1.{!index}. <apex:outputText value="{!qLine.Currency__c}"/>

@vijayk3327 vijayk3327 added documentation Improvements or additions to documentation question Further information is requested labels Sep 13, 2023
@vijayk3327 vijayk3327 self-assigned this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

1 participant