Skip to main content

Notifications

Community site session details

Community site session details

Session Id : EGUNnu5DMHVcfD4kkHVs7g
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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,662 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard