Domain 1 of 3 · Chapter 22 of 22

Manage variables

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing Designing and Building Integrated AI Agent Solutions in Copilot Studio premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • Four scopes, and what each one is for
  • Base types and the assignment that fixes them
  • Referring to a variable in a Power Fx formula
  • System variables: context you should not recollect
  • Declaring a topic's input and output parameters
  • Where control returns after a redirect
  • Clearing session state on purpose
  • Letting an external source set a global variable
  • Consuming environment variables inside an agent
  • Topic checker and the orphaned variable
  • How these choices show up in questions

The four variable scopes, compared on the properties that decide which one to use

PropertyTopic variableGlobal variableSystem variableEnvironment variable
Where you can use itOnly the topic that creates it (the default scope)Every topic in the agentEvery topic in the agentEvery topic in the agent
Who sets the valueNodes in its own topic, or a caller through an input parameterAny topic, and an external source when the variable declares oneCopilot Studio, from the conversation and the signed-in userAn administrator or maker in Power Apps; read-only in Copilot Studio
Where it is definedA node in the topic, or the Variables panelA topic variable switched to Global (any topic can access)Built in to every agentA Power Platform solution
Power Fx prefixTopic.Global.System.Environment.
What it is forWorking state inside one piece of authored logicSession state several topics shareConversation and user context you should never recollectConfiguration that differs between environments

Decision tree

Value differs per environment,not per conversation?YesEnvironment variableEnvironment. read-only in the agentbound at publish; Secret at runtimeNoConversation or user contextthe platform already supplies?YesSystem variableSystem. conversation and user contextNoDoes only the collectingtopic read it?YesTopic variableTopic. the default scopeNoDoes one specific topicread it across a redirect?YesDeclared input or output parameterthe variable stays Topic. scopemapped on the Redirect nodeNoGlobal variableGlobal. many topics, one sessioncleared by the variable-clearing nodeAlways: prefix every referenceTopic. Global. System. Environment.US-style commas separate parameters

Cheat sheet

  • Use topic variables for state needed only in one topic
  • Use global variables for values shared across topics in one session
  • Use system variables for built-in conversation and user context
  • Keep a variable's type stable after its first assignment
  • Use Topic checker to clear publishing blockers
  • Qualify every Power Fx variable reference by scope
  • Use US-style numeric and parameter separators in Copilot Studio Power Fx
  • Declare topic variables as inputs or outputs before passing them
  • Expect a redirected topic to return to its caller by default
  • Clear global values explicitly when starting clean
  • Clear generative conversation history separately from global variables
  • Use read-only environment variables for deployment-specific values
  • Republish to bind changed nonsecret environment-variable values
  • Configure an external global variable with an exact name, timeout, and default

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. Variables overview - Microsoft Copilot Studio
  2. Work with global variables - Microsoft Copilot Studio
  3. Understand error codes - Copilot Studio troubleshooting
  4. Work with variables - Microsoft Copilot Studio
  5. Create expressions using Power Fx - Microsoft Copilot Studio
  6. Manage topic inputs and outputs - Microsoft Copilot Studio
  7. Orchestrate agent behavior with generative AI - Microsoft Copilot Studio
  8. Manage topics - Microsoft Copilot Studio
  9. Use system topics - Microsoft Copilot Studio
  10. Use environment variables in Power Platform solutions - Power Apps