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 / Replace characters in ...
Power Automate
Unanswered

Replace characters in an array

(0) ShareShare
ReportReport
Posted on by 63
Hi all, 
 
I am trying to replace characters in an array. 
 
The below is as below:
 
[
  "| What is the Employee ID of the person you want to move? | [\"4\"] |",
  "| What is the Employees Forename | [\"Test\"] |",
  "| What is the Employee's Surname | [\"Person\"] |",
  "| What is the effective date of the change? | [\"25/11/2024\"] |",
  "| Who will be the Employee's future line manager? | [\"test@domain.com\"] |"
]
 
To get the above array, we have to convert to XML and then using a Select using the below to link the questions and answers.
addProperty(item(), 'Answer', xpath(outputs('XML'), concat('//root/array[Sequence/text()="', item()['Sequence'], '"]/Answer/text()')))
 
We then use another Select action from the output of the above and use 
concat('| ',item()?['Question'],' | ',item()?['Answer'],' |')
 
We then want to use the array in an Approvals action, as below, and we are currently using 
join(body('Map_Questions_and_Answers_for_Approval'),decodeUriComponent('%0A'))
to do this.
 
 
But the output received by the Approver still has [" and "] around each Response. How can we remove these in the easiest way?   Converting to a string, using replace() and then back into an array is really complicated, as we have to use XML to get the array in the first place.
 
Many thanks, 
SD.
 
 
Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,828 Most Valuable Professional on at
     
    You can use a json and a join to convert the string array to a value.
     
    Below is an example
     
    Question key
    split(item(), '|')[1]
    Response key
     
    join(json(split(item(), '|')[2]), '')
     
     
    Test result
     
  • sausage_dog Profile Picture
    63 on at
    @Expiscornovus - Thanks. However, in the Approval action, we can't use HTML... it has to be Markdown... :(
  • Expiscornovus Profile Picture
    33,828 Most Valuable Professional on at
     
    The Create HTML table was just to show that it is an array without the special characters. You can ignore that Create HTML table action, you don't have to use that. The suggested approach is in the Select action.
     
    I have updated my example to your situation (with the markdown), if that helps?
     
    1. Second select uses the same name and concat function in the map field
    concat('| ',item()?['Question'],' | ',item()?['Answer'],' |')
    2. Compose action to create the markdown table
    | Question | Response |
    |-----------|:-----------:|
    @{join(body('Map_Questions_and_Answers_for_Approval'),decodeUriComponent('%0A'))}
     
     
     
    Test result
     
  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    The text() in the xpath returns an array. Hence the brackets.
    Simply take the first value from this array:
    addProperty(
    	item(),
    	'Answer', 
    	first(
    		xpath(
    			outputs('XML'),
    			concat('//root/array[Sequence/text()="', item()['Sequence'], '"]/Answer/text()')
    		)
    	)
    )
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard