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

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Item is NULL in function and not by itself?!

(0) ShareShare
ReportReport
Posted on by 16

Hey all,

 

just struggling with an expression I am trying to use. I get it from a SharePoint list but the actual string has the HTML tags included which I don't want, so I try make an expression to get rid of them: replace(item()?['Ans'], '<[^>]+>', ''). But it says: 'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.

But if I just use Ans from dynamic content it works fine and that is: item()?['Ans']. How can it be NULL in my function but not by itself?!

 

So confused about this. Any help appreciated.

GRK123_0-1691079226265.png

 

 

I have the same question (0)
  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: Item is NULL in function and not by itself?!

    Hi @GRK123 

     

    To check for null values in field, you need to modify the expression. Pls try using the below expression:

    if(equals(item()?['Ans'],null),'',replace(item()?['Ans'], '<[^>]+>', ''))

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • GRK123 Profile Picture
    16 on at
    Re: Item is NULL in function and not by itself?!

    So it works in the fact that is just prints out ANS, but this is what it gives out as an example:
    <div class="ExternalClass8F2C0582EBB64A639BA8870A413A8D03">When sensor is purchased, Accessories has a waterproof cap for the Ethernet connector. Use this.</div>
    I want it to be this: When sensor is purchased, Accessories has a waterproof cap for the Ethernet connector. Use this.

  • GRK123 Profile Picture
    16 on at
    Re: Item is NULL in function and not by itself?!

    So it works in the fact that is just prints out ANS, but this is what it gives out as an example:
    "<div class="ExternalClass8F2C0582EBB64A639BA8870A413A8D03">When sensor is purchased, Accessories has a waterproof cap for the Ethernet connector. Use this.</div>"
    I want it to be this:
    "When sensor is purchased, Accessories has a waterproof cap for the Ethernet connector. Use this."

    Any ideas on how this can be done?

  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: Item is NULL in function and not by itself?!

    Hi @GRK123 

     

    If you want to extract the data from html or xml file, you can use xpath() function in the expression.

     

    Pls use the below expression to extract the desired data:

    if(equals(item()?['Ans'],null),'',xpath(xml(item()?['Ans']),'string(/div[@class="ExternalClass8F2C0582EBB64A639BA8870A413A8D03"])'))
    In the above expression, we are checking if "Ans" field is null or empty. If it is null or empty then we are returning empty string else we are parsing the xml using xpath and return the string value of html div tag.
     
    If this reply helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.
     
    Thanks
  • GRK123 Profile Picture
    16 on at
    Re: Item is NULL in function and not by itself?!

    Currently getting this error:
    'The template language function 'xml' parameter is not valid. The provided value cannot be converted to XML: 'The 'br' start tag on line 1 position 376 does not match the end tag of 'div'. Line 1, position 493.'. Please see https://aka.ms/logicexpressions#xml for usage details.'.

     

    Not sure what this means

  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: Item is NULL in function and not by itself?!

    Hi @GRK123 

     

    The html is not well formed, <br> tag has no end tag. Pls try using this:

    if(equals(item()?['Ans'],null),'',xpath(xml(replace(item()?['Ans']),'<br>',''),'string(/div[@class="ExternalClass8F2C0582EBB64A639BA8870A413A8D03"])'))

    here, we are replacing <br> in the input 'Ans' field with empty string.  If it still doesn't work, then pls share the html code for 'Ans' field.

     

    If this reply helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • GRK123 Profile Picture
    16 on at
    Re: Item is NULL in function and not by itself?!
    Still not working. How do I share the HTML code for Ans field, do I need to go to the sharepoint list to get it?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 722 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 461 Moderator

#3
developerAJ Profile Picture

developerAJ 283

Last 30 days Overall leaderboard