web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / How to set a variable ...
Copilot Studio
Unanswered

How to set a variable as Null if the user does not provide any value

(1) ShareShare
ReportReport
Posted on by 12

Hi,

 

I have made a bot that asks a bunch of questions and then using the variables calls flow to send an email. The problem is that some variables are optional for the user (the chat flow is made like that) and when some variables are not provided, the flow call is executed and the questions are asked again.

 

Is there any way to assign variable a null value?

Categories:
I have the same question (0)
  • CU22081450-0 Profile Picture
    Most Valuable Professional on at

    Hi @ankit3 ,

     

    Can you take some pictures of your scenario?

     

    But side your pictures, you can see if this topic help you: https://powerusers.microsoft.com/t5/Power-Virtual-Agents-Forum/Conditition-to-test-a-variable-for-an-empty-string/m-p/430063#M475

    The solution is: "[...] are you trying to handle a return variable from a flow and do a condition in PVA based on that? I had the same issue and I had to add some logic in the flow to set the value of the variable to "NotFound" and then pass that back into the PVA so that the condition had something to select. Yes i know, workaround to fix a simple feature gap but you know... Let's be agile!"

     

  • Verified answer
    Ashish2012 Profile Picture
    478 on at
  • ankit3 Profile Picture
    12 on at

    Thanks for your reply.

     

    Attaching screenshot of the PVA where I'm calling flow. You can see there are around 8 variables. The flow is executed perfectly if all 8 all present but of user chooses not to provide the "CompanyName", the flow is not executed and user is asked to provide "CompanyName" again. What I'm asking is that, is there any way I can identify if a variable is empty and if yes, assign "Null" to it so that flow can be executed?

     

     
  • dougmaloney Profile Picture
    59 on at

    Did you find a solution for this ? I have the same problem.

     

    1. Prompt the user "Were you born in Australia or Overseas" (multiple choice).
    2. If they answer "Overseas" PVA prompts "Please enter the country you were born in" (text).
    3. Call action, passing the variables from both prompts.

    If the customer selects "Australia" in the first prompt, it means the  second prompt is not issued, and the resulting variable is not assigned.

     

    When I come to call my action in 3, PVA prompts for the missing variable "Please enter the country you were born in" BEFORE calling the action. The receiving action has that variable set as "optional".

     

    I've tried a few workarounds including assigning the missing variable using another different action, but I run into the same problem when it returns. 

     

  • ankit3 Profile Picture
    12 on at

     I haven't found the solution yet. I've reached out to Microsoft team and they suggested to use "Receive request from Power Virtual Agent" in Power Automate but that doesn't work as well. I'll post the solution here once I get the final resolution.

  • dougmaloney Profile Picture
    59 on at

    I've found a solution to this which works, but ... It's complicated.

     

    I use an Excel online spreadsheet as temporary storage for my variables, keyed off a guid which is generated by an action at the top of the PVA flow.

     

    The same action returns a set of default values for the variables which might be unset/null.

     

    Every time a question is asked in the PVA flow, I call another action either with the value of the variable OR for all other cases, the default value. This action stores the values in the spreadsheet.

     

    At the end of my flow I have yet another action which uses the original guid to retrieve the correct row and values from the spreadsheet. 

     

    It took some thought, and some time to setup, but it does work.

    If it's going to be helpful I'll post a video of how I did it.

  • ankit3 Profile Picture
    12 on at

    That sounds complex but good. Can you please share a video?

  • ankit3 Profile Picture
    12 on at

    Can you post a video please?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 255 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 205 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 101 Moderator

Last 30 days Overall leaderboard