Skip to main content

Notifications

Copilot Studio - Topic Creation & Management
Answered

How to add DisplayName to a JSONResponse to display choices

(0) ShareShare
ReportReport
Posted on by 6

Hello,

 

In a custom plugin i'm calling an API to retrieve a list of items, and i would like those items to be displayed as choices for the user in a DynamicClosedListEntity.

 

The items are in a table type variable, and i know that to be displayed as choices, each item must have a DisplayName property.

 

So i want to add this property for each item and to set its value to a concatenation of some of its properties.

 

I suppose the best way to achieve this is to rebuild a new variable in a SetVariable block, but i'm struggling in vain with FX functions. 

 

Is there anyone to help me?

 

Thank you

 

 

 

 

 

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: How to add DisplayName to a JSONResponse to display choices

    Yes, I think so. Although I don't know if there's a better way to rename a table property in Power Fx?

  • MiguelMeloOP Profile Picture
    MiguelMeloOP 6 on at
    Re: How to add DisplayName to a JSONResponse to display choices

    The JSON comes from this mocked API and it looks like this:

    [
     {
     "id": 1,
     "name": "Pizza Heaven",
     "address1": "Kungsgatan 1",
     "address2": "111 43 Stockholm",
     "latitude": 59.336078,
     "longitude": 18.071807
     },
     {
     "id": 2,
     "name": "Pizzeria Apan",
     "address1": "LÃ¥ngholmsgatan 34",
     "address2": "117 33 Stockholm",
     "latitude": 59.315709,
     "longitude": 18.033507
     }
    ]

     

    So does it mean that i have to manually re-assign each known property?

  • Verified answer
    HenryJammes Profile Picture
    HenryJammes on at
    Re: How to add DisplayName to a JSONResponse to display choices

    Hi @MiguelMeloOP 

     

    What does your JSON look like?

    In the set variable node, using Power Fx, you could use a variation of this formula:

     

    ForAll(
     Topic.MyTable,
     {
     DisplayName: name,
     OtherProperty: property,
     ID: id
     }
    )

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,567

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard

Featured topics