web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to get values of c...
Power Pages
Answered

How to get values of choice column in power pages using JS or html?

(0) ShareShare
ReportReport
Posted on by 46
Hi Folks,
 
I'm building a power pages site completely using html, CSS and JS. I'm not using forms or views. I have a pop up with few checkboxes inside it in a web page. The code is in the html of the page. I have a dataverse multi select choice column in a table. I want to retrieve the label and value for all options in this choice column and use it as label for all checkboxes. And when I save it back I need the values to be used.
 
But I'm unable to find any working methods of retrieving choice column values. I tried power pages API (entity definitions) and liquid code (entities.tableName0 both did not wokr.
 
Any thoughts?
 
Thanks
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,433 Super User 2025 Season 2 on at
     
    For this you have to call the Dataverse web api as such
     
    Make sure that where I said v9.x that you use .1 or .2 depending on your version. Its most likely .2 but just to be safe.
     
     
    Now you need to use this in your javascript
     
    
    NOTE I had to put in carriage returns because its too long
    just connect it back together
    
    If you need help showing it in your html let us know, otherwise
    you will use your optionData to build your dynamic HTML.
    
    async function retrieveMyChoiceLabelsEtc() {
    const response = 
    await fetch
    ("/_api/data/v9.x/EntityDefinitions(LogicalName='entitylogicalname')
    /Attributes(LogicalName='columnlogicalname')
    /Microsoft.Dynamics.CRM.PicklistAttributeMetadata?
    $select=OptionSet", {
            headers: {
                "Accept": "application/json"
            }
        });
        const returnedData = await response.json();
        const optionData = returnedData.OptionSet.Options.map(opt => ({
            value: optionData.Value,
            label: optionData.Label.LocalizedLabels[0].Label
        }));
    
        return optionData;
    
     

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey
  • Lucas001 Profile Picture
    2,434 Super User 2025 Season 2 on at
     
    what is your exact usecase?
    You could also get your records etc with a a FetchXML statement which could be easier.
    For using these I would highly recommend the FetchXML Builder from the XRMToolbox
  • Verified answer
    Fubar Profile Picture
    8,361 Super User 2025 Season 2 on at
    Unless there is a reason that the values need to be dynamic (e.g. you are filtering based on other values that may change), I would retrieve them in Liquid fetchxml as it runs server-side so no having to wait for another api response before working with them.
     
    What you are looking for are held in the stringmap table. Quick search gave this video which shows what you need.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 78 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 75

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard