Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 7q2JgCNFTm724pnnVGex6o
Power Automate - Building Flows
Unanswered

Set Variable empty value

Like (0) ShareShare
ReportReport
Posted on 19 Sep 2023 17:58:01 by 158

I am trying to build a multiple approval workflow the will return the approval comments in the email I tried setting it up multiple times. 

Test 1

  • If approved, update SharePoint
  • send 2nd approval to manager with associate approval comments in email from update SharePoint
    • creates an apply to each for every approval comment (Form is built to have up to 3 associate approval comments)

Test 2

  • Create an initialize variable for each approval comment so apply to each does not happen on manager approval flow
    • error message when Associate 3 comment section blank
      • How do I set my variable to return NA if null?

KhrystinaM_0-1695146238098.png

 

  • KhrystinaM Profile Picture
    158 on 26 Sep 2023 at 16:57:18
    Re: Set Variable empty value

    @Sundeep_Malik Hello, I tried both options on the set variable field and got this error. 

     
    ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_-_Associate_3' failed: the result of the evaluation of 'foreach' expression '@outputs('Associate_3_Approval')?['body/responses']' is of type 'Null'. The result must be a valid array.
  • Sundeep_Malik Profile Picture
    6,480 on 19 Sep 2023 at 19:11:41
    Re: Set Variable empty value

    @KhrystinaM 

     

    You can directly write the following expression:

     

    if(equals(items('Apply_to_each_-_Associate_3')?['comments'],''),null,items('Apply_to_each_-_Associate_3')?['comments'])
     
     
    If the above does not work, replace '' with null
     
    I hope this helps 🙂
  • KhrystinaM Profile Picture
    158 on 19 Sep 2023 at 19:04:00
    Re: Set Variable empty value

    @Sundeep_Malik I input the following. 

     

    if(equals(variables('Associate_3_Approval')?['body/outcome']),null),'NA',variables('Associate_3_Approval')?['body/responseSummary']))
     
    I'm getting this error
    Flow save failed with code 'WorkflowRunActionInputsInvalidProperty' and message 'The inputs of workflow run action 'Set_variable_4' of type 'SetVariable' are not valid. Self reference is not supported when updating the value of variable 'varAssociate3'.'.
     
    Should my initialize variable have a value? I tried adding a value and removing the set variable, but I got an error for that as well. 
    KhrystinaM_0-1695150180922.png

     

  • Sundeep_Malik Profile Picture
    6,480 on 19 Sep 2023 at 18:28:48
    Re: Set Variable empty value

    Oh my bad.

     

    Actually replace variables('VariableName') 

    part with the comment expression. 

     

     

  • KhrystinaM Profile Picture
    158 on 19 Sep 2023 at 18:19:54
    Re: Set Variable empty value

    @Sundeep_Malik Do I apply option 2 to the set variable? I tried that and I'm getting an error. 

    KhrystinaM_0-1695147564290.png

    KhrystinaM_1-1695147573782.png

     

  • Sundeep_Malik Profile Picture
    6,480 on 19 Sep 2023 at 18:02:30
    Re: Set Variable empty value

    Hey @KhrystinaM 

     

    You can write a similar expression as below:

     

    1)

    If(equals(variables('VariableName'),''),'NA',variables('VariableName'))

     

    2)

    If(equals(variables('VariableName'),null),'NA',variables('VariableName'))

     

    I hope this helps 🙂

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 > Power Automate - Building Flows

#1
David_MA Profile Picture

David_MA 130 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 125

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 112 Super User 2025 Season 1

Overall leaderboard