cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver II
Resolver II

Attachment control, change file name

I am using the attachment control to save files to sharepoint using this code

 

Set(VarDemoFromAttachmentControl;JSON(Image8.Image;JSONFormat.IncludeBinaryData))
;;Set(VarImage;Image8.Image)//
;;Set(Base64Only;Mid(VarDemoFromAttachmentControl;Find(",";VarDemoFromAttachmentControl)+1;Len(VarDemoFromAttachmentControl)-Find(",";VarDemoFromAttachmentControl)-1))
;;Set(VarFileName;Last(AttachmentControl.Attachments).Name)
;;UpdateContext({lOmschrijving:VarFileName})
;;Set(VarFileLink;PowerAppsToSharePoint_3.Run(Last(AttachmentControl.Attachments).Name;Base64Only).sharepointfilelink)
;;Reset(AttachmentControl)
;;Reset(TextInput8)

 


I got from a Sean Young video.

I found that if I get a file of which the filename already exists it is just overwritten without any warning.
I tried doctoring the filename with a piece of guid

 

Set(VarDemoFromAttachmentControl;JSON(Image8.Image;JSONFormat.IncludeBinaryData))
;;UpdateContext({FileGUID:Right(GUID();6)})
;;Set(VarImage;Image8.Image)//
;;Set(Base64Only;Mid(VarDemoFromAttachmentControl;Find(",";VarDemoFromAttachmentControl)+1;Len(VarDemoFromAttachmentControl)-Find(",";VarDemoFromAttachmentControl)-1))
;;Set(VarFileName;Last(AttachmentControl.Attachments).Name)
;;UpdateContext({lOmschrijving:VarFileName})
;;Set(VarFileLink;Substitute(PowerAppsToSharePoint_3.Run(Last(AttachmentControl.Attachments).Name;Base64Only).sharepointfilelink;Last(AttachmentControl.Attachments).Name;FileGUID & Last(AttachmentControl.Attachments).Name))
;;Reset(AttachmentControl)
;;Reset(TextInput8)

 


but it just saves with the same name although variable varfilelink does look good.
If I add the guid to the back of varfilelink (molesting the file extension) it DOES save the file with the wrong extention to sharepoint.

Of course this can all be easily solved, just a trifle, but .. how?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver II
Resolver II

Re: Attachment control, change file name

Already found a soulution. Only accept extentions eh? Well just Add the guid and then the .extention again. An unique filename at last

View solution in original post

1 REPLY 1
Highlighted
Resolver II
Resolver II

Re: Attachment control, change file name

Already found a soulution. Only accept extentions eh? Well just Add the guid and then the .extention again. An unique filename at last

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,281)