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 : B7TJ4Q7VZNEE0jRGFUZ+QV
Power Automate - Building Flows
Answered

'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.

Like (1) ShareShare
ReportReport
Posted on 4 Feb 2021 01:39:58 by 89

I have seen a few requests about this error in the forum but no solution yet so I thought I'd post what I found.

 

My flow needs to use the replace function on an output from the trigger.

 

As an initial test I just put the output from the trigger directly into my output (create a row in a spreadsheet on SharePoint). This worked fine which says the flow is detecting data in that field.

 

Next, I used the expression editor to wrap the trigger output into the replace function. In the expression editor I typed  

 

replace(

 

 

then used the Dynamic content chooser to find the trigger output, and entered my new and old texts. The result was 

 

replace(triggerOutputs()?['body/2']?[' What activities.topics were covered during this session?'],'-','|')

 

 

This failed with the error in the error

 

'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.

 

 

In the Run History I checked the output of my trigger field, there was an output:

 

"2. What activities/topics were covered during this session?": "-Going Digital"

 

 

So, I noticed that the chooser had made an error in the field name, it had split it at the dot (.) character and converted the / character to a dot. So I manually edited my expression to:

 

replace(triggerOutputs()?['body/2. What activities/topics were covered during this session?'],'-','|')

 

Probably predictably that failed. 

 

Then I just dropped my trigger field straight into my flow output field using the Dynamic content chooser and ran the flow. It ran successfully and dropped the unprocessed output into my spreadsheet. This again proved that the field is accessible and has a non null value.

Next, in an inspirational moment, I hovered over the field in my output, the one I had dropped in directly using the Content chooser and I noticed the reference to my trigger field was different - it has replaced the / character in the field name with ~1

2021-02-04 12_35_09-Edit your flow _ Power Automate - Brave.png

 

So, my final step was to use that trigger reference directly in my replace statement thus:

 

replace(triggerOutputs()?['body/2. What activities~1topics were covered during this session?'],'-','|')

 

and Bingo! it worked !

I have the same question (0)
  • Verified answer
    KarlinOz Profile Picture
    89 on 04 Feb 2021 at 01:40:51
    Re: 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.

    The solution is in the original post.

  • Community Power Platform Member Profile Picture
    on 31 Aug 2022 at 14:06:14
    Re: 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.

    Thank you for taking the time to post a solution.  A similar issue has been giving me a headache for more time than I care to admit.  I was trying to update values in an Excel table where the UserName column sometimes had a space and dash in the name if no middle initial was present.

     

    Using an expression with dynamic content in the middle I came up with

    replace(outputs('List_rows_present_in_a_table')?['DisplayName'],' -', '')

     

    That kept failing with "'The template language function 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'"

     

    After adding just UserName as  dynamic content, hovering over the object showed

    items('Apply_to_each')?['DisplayName']

     

    I updated the replace expression as shown below and it worked.

    replace(items('Apply_to_each')?['DisplayName'],' -','')

     

  • takolota1 Profile Picture
    4,933 Moderator on 31 Aug 2022 at 14:25:04
    Re: 'replace' expects its first parameter 'string' to be a string. The provided value is of type 'Null'.

    @KarlinOz @Anonymous 

     

    For any scenario with replace or other expressions that do not accept null, I just add some simple parts to my expression…

    If(empty(item()?['InsertColumnName']), null, item()?['InsertColumnName'])

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…

Tom Macfarlan – Community Spotlight

We are honored to recognize Tom Macfarlan as our Community Spotlight for October…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 707 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 499 Moderator

#3
chiaraalina Profile Picture

chiaraalina 312

Last 30 days Overall leaderboard