Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Copilot Studio - General
Answered

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?

  • ankit3 Profile Picture
    12 on at
    Re: How to set a variable as Null if the user does not provide any value

    Can you post a video please?

  • ankit3 Profile Picture
    12 on at
    Re: How to set a variable as Null if the user does not provide any value

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

  • dougmaloney Profile Picture
    59 on at
    Re: How to set a variable as Null if the user does not provide any value

    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
    Re: How to set a variable as Null if the user does not provide any value

     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
    Re: How to set a variable as Null if the user does not provide any value

    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
    Re: How to set a variable as Null if the user does not provide any value

    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?

     

     
  • Verified answer
    Ashish2012 Profile Picture
    478 on at
  • CU22081450-0 Profile Picture
    Most Valuable Professional on at
    Re: How to set a variable as Null if the user does not provide any value

    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!"

     

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Copilot Studio - General

#1
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 25

#1
Pablo Roldan Profile Picture

Pablo Roldan 25

#3
stampcoin Profile Picture

stampcoin 10

Overall leaderboard