Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Copilot Studio - Topic Creation & Management
Suggested answer

Error: Variable is being set to incorrect type but error shows correct type?

(2) ShareShare
ReportReport
Posted on by 19
Error: Variable is being set to incorrect type. Assigned: Closed List Option Set, Expected: Closed List Option Set
 
I have hit a roadblock when attempting to assign a global variable with a local variable value inside one of my topics. Searching the web has produced users with similar issues but no working resolution path so far.
 
Scenario:
 
The topic uses the States entity to extract what state the user is referring to in a dialog prompt. A conditional statement then filters based on the state selected. 
 
Branch 1
If State = ABC display choices from 'CustomEntityClosedListABC' save user choice as 'LocalVariableABC' Confirm selection with user, save 'GlobalVariable' as 'LocalVariableABC' This path is working as intended with no errors
 
Branch 2
If State = XYZ display choices from 'CustomEntityClosedListXYZ' save user choice as 'LocalVariableXYZ' Confirm selection with user, save 'GlobalVariable' as 'LocalVariableXYZ' This path produced the error (screenshot below)
 
I have tried a few options such as recreated the entities, creating new variables, setting variable types prior to the conditional path, cutting out the local variable and saving the choice direct to the global, etc. If I try to use the GlobalVariable anywhere else besides the first path of a conditional I receive this error.
 
Solution Needed: A way to filter by state to direct bot to use state specific customentity list and then save that choice both in a topic variable and again in a global variable for a future topic
 
Categories:
  • Suggested answer
    Inogic Profile Picture
    1,023 Super User 2025 Season 1 on at
    Error: Variable is being set to incorrect type but error shows correct type?
    Hi,
     

    What's Causing the Problem:

    You are using multiple drop-down lists (choices) in your bot for different states like ABC and XYZ.
    Even though these look like regular choices to the user, behind the scenes each choice list is a different “type”, and Power Virtual Agents doesn’t allow mixing them.
    So, when you try to save a value from one list into a variable meant for another list, the bot gives an error even though they both look like "choices".

    Simple Solution That Works:

    We will save the selected value as plain text (just the label) instead of saving it as a “choice” type.
    This way, you can use that text anywhere, no matter where it came from.

    How to Fix It Step-by-Step:

    1. Change your Global Variable to Text type
    • Go to your Global Variables
    • Find Global.Agency_Name
    • Change its type from Choice to Text
    1. When user picks from a choice list (like CustomEntityClosedListABC):
    • Save the selected option label (not the whole choice) to a text variable, e.g. VarABC_Text
    1. Assign the local text variable to the global one:
    • Set Global.Agency_Name = VarABC_Text
    This will now work with any choice list, because you're only dealing with text, not the special "choice object" types.

    Example:

    If State = ABC:

    • Show drop-down from CustomEntityClosedListABC
    • Save label of selected item to: LocalChoiceABC_Text
    • Then: Set Global.Agency_Name = LocalChoiceABC_Text

    If State = XYZ:

    • Show drop-down from CustomEntityClosedListXYZ
    • Save label of selected item to: LocalChoiceXYZ_Text
    • Then: Set Global.Agency_Name = LocalChoiceXYZ_Text
    Hope this helps.

    Thanks!
    Inogic

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics