Fetch Optionset Labels from String Maps Table using Flow or JavaScript

    String Maps table in Dataverse contains the details of Option set fields which are present in that organization. It contains details like Object Type code, Attribute Name, Attribute Value, Value, Display Order, and Organization ID. The response of the string maps API looks like the below image.

List Option set Labels using Power Automate

  • After the Manual trigger gets added to the flow, add a new step and select the List Rows action from Dataverse connector.

  • Select Table name as String Maps and add a filter as objecttypecode eq 'account' and attributename eq 'address1_shippingmethodcode'.

  • Then add Create HTML Table connector to list those options we got from the previous action.

  • Save the flow and click Run. After running, get into any of the successful run, and you have got to see the options from the option set are listed in the HTML table.

List Option set Labels using JavaScript

  • Go to your favourite IDE and create a JavaScript file.
  • Add the below code to fetch the Option set labels of the particular field.
  • Create a JavaScript Web resource and upload the .js file to it. Then hit save and publish.

  • Navigate to the main form in the maker and add the function name to the on load event of the form. Pass the parameters which are necessary for the function. In this, I have passed the object type code (entity name) and attribute name (field – logical name) as the parameter.

  • For this article, I have used the account entity and shipment method option set as attribute.
  • Save and Publish the form. Then move to the app and load the form.
  • The options are listed in the alert box like below.

Summary

     You can use this string maps table to fetch option set labels and values from any table in Dataverse. This blog describes the fetching of option set labels from string maps table using Power Automate and JavaScript. You can use this in Canvas App or in plugins to fetch option set data.

Have a Good day!

Tamilarasu Arunachalam

Post a Comment

Previous Post Next Post