Copilot Studio Dynamically retrieve “question” choices from a SharePoint list | List variable options

Note on how to dynamically retrieve question choices from a SharePoint list in Copilot Studio.

スポンサーリンク

What we want to do

Created in a previous post, the question “Leave Types” within the topic “Leave Requests”,
dynamically retrieved from the SharePoint list.

Construction

First, create a connection to SharePoint. Under “Call Actions,” from “Connectors,” choose “Get Multiple Items”.
connect to SharePoint.
Pick a site and list that defines the type of vacation,
*We can select a site or list by pressing inside the text box, not the [>]button.
Put the vacation type table obtained from the SharePoint list into a variable (vacationTypes).
Then change the “Question” node’s [Specific] to [List Variable Options],
set the list variable to the value retrieved from SharePoint earlier.
However, if the variable is set as is, an error will occur if the “DisplayName” property does not exist,
Use the AddColumns function to add the DisplayName property.
*ForAll is also fine, as described below.
Finally, assign the value selected by the user to the variable (type),
use that value (this time simply to send out a message).

This completes the topic.

Operation check

When we start a topic, you will be asked to make a connection,
so create the connection,
and start the topic again to see the SPO list options.
When the user selects a vacation type, the variable is assigned the contents of the list item.
When you add a new vacation type to the list,
reflected in the question.

So it was very easy to work with the SPO list.

Extra: List variables can also be string arrays.

The values to be set in the list variable can be a string array, so the ForAll function can be used to set an array of just the column “title”.
Then, the variable to which the user’s selected value is assigned becomes a “string” type,
and can be used as is because it is a string.

ForAll is easier if you don’t need ID columns and such and don’t need to get them as objects.

Copied title and URL