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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow not working due t...
Power Automate
Answered

Flow not working due to 'null' - adding link of Forms attachment to Sharepoint List

(0) ShareShare
ReportReport
Posted on by 37

Hello there,

 

I have created an automation to add a Forms attachment into a Sharepoint List, under a Hyperlink column as below:

phishseng91_1-1623999885032.png

 

phishseng91_0-1623999403843.png

I used the expression first(body('Parse_JSON_-_Get_Forms_attachment'))?['link']

 
The problem is now that if there are no attachments, it creates an error where the first() expression expects an array but gotten a null instead. How do i edit the expression to work for a possible 'null' situation as well?
Categories:
  • Verified answer
    Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @phishseng91,

     

    You could check if the body of the Parse Json action is empty. If not, collect the first item.

     

    Below is an example of that approach.

    Replace the 'Not empty, do something' with whatever you want to do. In this case collecting the first item of the array.

    if(empty(body('Parse_JSON_-_Get_Forms_attachment')), '', 'Not empty, do something')

     

  • phishseng91 Profile Picture
    37 on at

    Hello @Expiscornovus !

     

    Thank you so much! It works now!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Bro, PLEASE help me!!! 

    This solution that you gave us really worked! But I'm trying to set if the 'Parse Json' is NOT EMPTY, then made a "hyperlink" to display in my Sharepoint list column...

     

    if(empty(body('Parse_JSON_2')), '', '<a href="@{variables('my variable which gets the attachment')}">Image</a>') ... But the Automate says it INVALID... 

    Please, could you help me?

    Today my flow its like this:
    ELISILU_0-1662485803534.png

     





  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Anonymous,

     

    It looks like in the expression you are referring to the body of a Parse Json 2 action. However, in your screenshot I only see a Parse Json 8 action. Can you change that in your expression? 

     

    And in which action are you trying to use that expression? Within the Create File 8 action in the apply to each loop?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Expiscornovus, thank you for answer me and for the tips!

    First, I need to explain to you that I've just send the wrong print hahah...

    So, here it goes...
    I have 3 conditions with that estructure ↓

    ELISILU_0-1662587807776.png

    If the user upload an attachment, my conditions runs on right side (if no side)... 

    But at the end of my flow I have an action 'Create Item' on Sharepoint... And there is my problem... 

    ELISILU_1-1662588309972.png

    If you look those columns named: "Evidências (5S5), Evidências (5S6), Evidências (5S7)", they're resposible to get the attachments link...
    Before my necessity to create this "if", I've inserted an href like this: <a href='Anexo 5S6'>Image</a>..

    But when the user don't upload an attach, the flows was inputing only the word "Image"...

     

    I want to insert the attachment's link on those columns ONLY if the user has entered an attach, if no i want to keep those fiends in blank...

     

    if(empty(variables('Anexo 5S6')), '', '<a href='Anexo 5S6'>Image</a>') - but it doesnt works!!!

    I need to if my variable 'Anexo 5S6' IS NOT empty, then shows de HREF in my SP column (multiline of string)... like this ↓
    ELISILU_2-1662588806034.png

     



  • Expiscornovus Profile Picture
    34,005 Most Valuable Professional on at

    Hi @Anonymous,

     

    Can you try the expression below:

    if(empty(variables('Anexo 5S6')), '', concat('<a href="',variables('Anexo 5S6'),'">Image</a>'))
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Expiscornovus You're the best!!!!!!!! Thank you for that.... I was more than 2 weeks trying to solve this "bug", but all the forums/solutions that I've saw doesn't helps!!!

    Now, with this expression you gave me it works perfectly!!!!

    Thank u again!!! @Expiscornovus 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 288 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard