cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Iterate through fields of a form

Hi all,

 

I'm trying to sanitize the fields from my form before they can be sent in an email. This allows me to block certain injections such as html, javascript, etc.

 

I want to sanitize all of my fields returned. I have a general idea of how to sanitize them, my problem is more on going through all my fields that my form has. I can't put the Body returned by the form in an apply to each like I tried to do, because Body is an Object. I would need to translate what that object contains in an array that I can iterate through.

 

asdf.PNG

 

Any ideas ? Thanks

2 REPLIES 2
Gopala_Krishna
Super User
Super User

@Anonymous 

You can make use of the create array function in power automate to achieve this, you can pass all the object structure as a parameter inside the create array function and it convert it into an array. Later you can use this array to perform further operations.

 

Gopala_Krishna_0-1621354207379.png

 

For example you can initialise an array variable in the start and then you can set the array value using the expression, you can then make use of the array variable to loop through the items.

 

---------------------------------------------------------------------------------------------------------------------------------

If the information shared helps you, please consider giving a thumbs up 👍and mark solution as resolved

Anonymous
Not applicable

@Gopala_Krishna 

 

Thank you so much for the help. I was able to create an array based on the Object thanks to you.

 

I had an idea on how to do the sanitising but something seems to be wrong. Maybe if you can help me with that it would be very helpful also.

 

I created an array variable of my object called "RawInputs", and I also created another array variable called "InvalidChars" that contains the characters that I typically want to replace. The third variable I created is called "Temp", and is just used to make the replacing happen.

 

I make an "Apply to each" on my "InvalidChars" variable, and then I set my "Temp" variable to something like this :

 

replace(variables('RawInputs'), item(), '')

 

The problem with this is that it creates an error saying that the first parameter of replace has to be a string. Do you have any idea on how I could make this happen ?

 

Thanks again!

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,200)