cancel
Showing results for 
Search instead for 
Did you mean: 
WarrenBelz

Attaching Camera photos without either a Flow or JSON

There have been a methods posted regarding attaching camera photos using JSON. This one I think is simpler and involves a "re-purposed" attachment control.

In the below example, the “Photos” control is a normal (but re-purposed) Attachment Control on a form. The Attachment Control on the right is in another form displaying the same record to demonstrate that this works. The photo names are simply the time they are taken - you could use whatever you want here.

CameraAttach.gif

So what is happening?

Firstly, when the “Camera” icon is pressed, it does this OnSelect

UpdateContext({varPID: GUID()});
Collect(
    colImage,
    {
        Value: camAttach.Stream,
        DisplayName: Text(
            Now(),
            "[$-en]hhmmss"
        ) & ".jpg",
        Id: varPID,
        AbsoluteUri: ""
    }
)

You also need to set your Camera StreamRate - 100 (one tenth of a second) seems to work well.
And then the “Save” icon OnSelect

SubmitForm(frmPhoto);
Clear(colImage);
Refresh(SPListName)

You can probably delete the Refresh in most cases and would also clear the collection at Screen OnVisible.
The Update of the Data Card (generally standard for control I named acPhotos)

acPhotos.Attachments

The Items of the Attachment Control on the left is (instead of Parent.Default)

colImage

The most important bit is the changes to the acPhotos Attachment control

 

acPhotos.png

You are displaying the collection in the control instead of the attachments and have structured its fields to mirror a normal attachment. When the form is submitted, the control attaches all the photos (and then the code clears the collection). It also gives the user the ability to see what is being attached and delete if not required.
You could also display the photos in a Gallery underneath with the Items

 

acPhotos.Attachments

and the Image of

ThisItem.Value

for a better review before attaching.
My thanks also goes to @PhilM and his colleague @rilind for the inspiration to this process.

 

Meet Our Blog Authors
  • PowerApps Community Mentor 2018, Practicing surgeon and former Professor of Surgery, University of Illinois, Chicago.
  • Jill of All Trades (Power Apps, SharePoint, PowerShell, Exchange, Power Automate and odds & ends of assorted other things)
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • I'm Tim Leung - a PowerApps builder. In addition to PowerApps, my main interests include building software with SQL Server and Microsoft .NET. I'm the author of 'Beginning PowerApps' - the first published book on PowerApps. You can buy this from Amazon and other leading bookstores.
  • Systems developer
  • My name is Timothy Shaw and I create digital solutions using the Power Platform, Office 365, and Azure SQL and handle the IT for a small company in the energy sector. When not building the future :), I enjoy playing guitar, good (or really bad!) sci-fi, Xbox therapy, and hanging with my wife and son. Twitter: @ShortForTim