cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kmayes
Post Prodigy
Post Prodigy

Saving photos to photo library

Hi

I have an app that has a form for an end user. I am utilising the attachment data card from SP list within the form as the user needs to add mandatory photos, I have then enabled the photos to be visible in a gallery and added a drop down box so the user can identify what the photo is displaying. I intend to collect the data from the gallery to a collection however I need to then add the data to a photo library containing the same ID as the data that is going to the original SP list.
Is anyone able to suggest the best way of doing this?

1 ACCEPTED SOLUTION

Accepted Solutions

@Kmayes ,

If you are Patching the Form instead of SubmitForm, then there is no OnSuccess action (the Form was not submitted) and naturally the Flow will not run. However, you can do this on the Patch

Set(
   varPID,
   Patch(
       . . Your Patch in here . .
   ).ID
)

then replace Self.LastSubmit.ID with varPID when you run the Flow code straight after this.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

20 REPLIES 20
WarrenBelz
Super User III
Super User III

Hi @Kmayes ,

You might have a read of this blog of mine on SharePoint images in Power Apps 

You need to use Update file properties and pass the ID to the relevant linking field.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

WarrenBelz
Super User III
Super User III

Hi @Kmayes ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

v-xiaochen-msft
Community Support
Community Support

Hi @Kmayes  ,

Could you tell me:
Has the problem been solved?
Is there anything else I can help?


If your problem has been solved, please consider accept user’s post as a solution to help others. Thanks.

Best Regards,

Wearsky

Kmayes
Post Prodigy
Post Prodigy

@WarrenBelz Hi, Thanks for the link to the user guide on how to upload images in different ways. I'm trying to implement the SharePoint Library option. However slightly confused where the coding is to go. Below is what I'm working with

Kmayes_0-1611047514189.png

 

@v-xiaochen-msft Thanks for your message I haven't yet solved my issue as been offline for a while 🙂

Hi @Kmayes ,

Can you please share the code you have done to date - it is a bit hard to comment from the screen shot you have of an attachment when you now want to use a Library. For instance where are you getting the picture from to file?

There is code in the blog for instance for both the camera control and the add image control.

I haven't placed any code to date as confused where it was supposed to go. So on my screen is 6 Add picture icons (I have used this as my application needs one of each then I can utilise the naming convention from the picture). On change of the image the images are collected within a collection as per the image below. Ideally I would like to pass the images to a Photo Library that I have set up? 

(Below the pictures is a gallery where the images are shown so that the user can remove if required)

 

Not sure if this helps but this is what is on my on change of the first add image , If(UploadedImage1.Image=SampleImage,"",Collect(ImageCollection,{Image:UploadedImage1.Image,FileName:"Front Door"&Text(Now(),"[$-en-GB]yyyymmddhhmmssms") &".jpeg",ImageType:"Front Door"}))

 

Please let me know if you need more detail or more explanation?

 

Kmayes_0-1611048159692.png

 

@Kmayes ,

You have a photo that is currently a collection and now you want to them in in a Library?

If you use a ForAll(Collection) to run Saving in a SharePoint Library in the Blog it should do the job. As I mentioned, happy to help with code, but you need to apply your relevant values first.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

That is correct the images are being collected in a collection (is this not the best way?)

I've created the flow as mentioned in your blog for SharePoint Library, however confused as the beginning of your blog (in the Save to SP Library section) where the 'With' code is I'm not sure where you are using that, plus as per my second image the run requires the ask in apps info, which I assume is Run(CollectionName.column,  something)

1.JPG2.jpg

@Kmayes ,

Your Flow appears correct, but you need to have some understanding of what is going on with the JSON conversion back in Power Apps for this to work for you. You fortunately have a file name you can use - so the structure will be something like this (please try to understand this code as it is syntax guidance only - you will need to sort out the relevant values needed). 

ForAll(
   YourCollectionName,
   With(
      {
         vJSON: 
         With(
            {
               vJSONI: 
               JSON(
                  Image,
                  JSONFormat.IncludeBinaryData
               )
            },
            Mid(
               vJSONI,
               Find(
                  ",",
                  vJSONI
               ) + 1,
               Len(vJSONI) - 
               Find(
                  ",",
                  vJSONI
               ) - 1
            )
         )
      },
      YourFlowName.Run(
         FileName,
         vJSON,
         YourCurrentIDNo
      )
   )
)

 Note Image is not a good name for a field in your collection as it is a Reserved Word in Power Apps.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (63,976)