cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GCGJH
Frequent Visitor

Get File Content vs Convert File Expression

Hi, I'm trying to get a flow to convert to PDF but sometimes document might already be a PDF and needs to bypass the convert option. If it has to bypass the convert function, the "Create file" needs to look "Get file Content" instead of "Convert File".  I'm trying to learn the expressions any help will be appreciated.

 

I attempted to write an expression but I'm struggling. It feels like it should be simple.

My current expression: if(body('Convert_file_2'),0,body('Get_file_content_2'),0) gives me this error

Unable to process template language expressions in action 'Create_file_4' inputs at line '0' and column '0': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '4' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

 Thank you in advance!

 

PowerAutomate Help 2.png

PowerAutomate Help 3.png

1 ACCEPTED SOLUTION

Accepted Solutions

Thank you! This is basically what I had to create. I abandoned the formula and hard charged it.

 

PowerAutomate Help Solution.png

View solution in original post

9 REPLIES 9
Srini84
Frequent Visitor

@GCGJH 

 

Can you tell us where you are getting the document from? Is it from any input folder?

 

Thanks

Srini84
Frequent Visitor

Maybe you can try as below

Srini84_1-1651689679899.png

 

 

So Inside the if you can put the Convert File

 

Hope this may help you

 

Thanks

GCGJH
Frequent Visitor

Hi @Srini84 I'm getting the file from a OneDrive drive. PowerAutomate Help 4.png

GCGJH
Frequent Visitor

I got it to decide if the file is a PDF or not but when I go to "Create File," the flow does not know which choice to pull the information from.

Srini84
Frequent Visitor

@GCGJH 

 

So, above will work if the file is PDF there you can decide whether you skip the convert or need to convert

 

Also can you tell me what you want to do after that in detail?

 

Thanks

GCGJH
Frequent Visitor

After the flow decides that it is a PDF, I want to "Create a File" from that content

v-yujincui-msft
Community Support
Community Support

Hi @GCGJH ,

 

The if() function expects three parameters, the first parameter should return a boolean, but you provided 4 parameters.

Maybe you could add a Create file Action to both branches of Condition Action

vyujincuimsft_0-1652074146727.png

In addition, maybe you could try to use the following formula:

if(endsWith(items('Apply_to_each')?['{FilenameWithExtension}'],'.pdf'),outputs('Get_file_content_2')?['body'],outputs('Convert_file_2')?['body'])

 

Best Regards,

Charlie Choi

Thank you! This is basically what I had to create. I abandoned the formula and hard charged it.

 

PowerAutomate Help Solution.png

v-yujincui-msft
Community Support
Community Support

Hi @GCGJH ,

 

It seems that you found a way to achieve your needs.

Maybe you could consider marking your reply or mine as a 'Solution' to close the case.

 

Best Regards,

Charlie Choi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (3,727)