cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Emtu
New Member

How to get the last 16 characters of a file name saved to and insert it in an excel cell with using Flow

Hello All,

 

I am building a approval flow; once a file created in a specific sharepoint folder it triggers an approval flow. Briefly;

 

Trigger: A pdf file is saved to sharepoint folder (we have particular name format for the files uploaded, like vendorname_month_16digitdocnumber for example ABCCORP_02_GIS2020000012345)

1- an automated request goes to x person for registration of this document, 

     a) at this point flow creates a new row and gets the last 16 characters of the file name (GIS2020000012345) and inputs it in the column named "Document Number" in an excel sheet which is saved to a sharepoint folder.  

     b) next flow updates the row created in previous step>>a, and puts the date to the column named "Receiving Date" with the format "mm/dd/yyy"

      

21022020.png

 

Could you help me with this?

 

Thanks in advance!

 

Regards,

 

EmTu

1 ACCEPTED SOLUTION

Accepted Solutions

 

I have solved it with 

1-Initialize variable >>>    triggerOutputs()?['body/{FilenameWithExtension}'] to Value field

2-Compose   >>> last(split(replace(variables('DocumentNumber'),'.pdf',''),'_')) to Inputs field.

 

09032020.png

View solution in original post

4 REPLIES 4
abm
Super User
Super User

Hi @Emtu 

 

Use the expression below

 

last(split('filename','_'))

 

This will give GIS2020000012345

 

image.png

 

  



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

@abm  thank you for your quick answer but it gives filename as an output.

I have tried last(split(triggerOutputs()?['body/{Identifier}'],'_')) but this time it gave an output with file extension like  GIS2020000012345.pdf

 

21022020.png

 

Hi,

 

You could another  split as with '.' (dot) as delimiter as use first expression to get the result.

 

first(split('filename",'.'))

 

Or if you have fixed length for the full string then you could use substring() expression without using two splits.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

 

I have solved it with 

1-Initialize variable >>>    triggerOutputs()?['body/{FilenameWithExtension}'] to Value field

2-Compose   >>> last(split(replace(variables('DocumentNumber'),'.pdf',''),'_')) to Inputs field.

 

09032020.png

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,106)