The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
This post is nothing but a relatively boring technical walkthrough.. Which is as promised in the previous (hopefully not so boring) teaser post
Before you continue with this one, you may want to do some reading on how embedded canvas apps can be added to the model driven apps.
I would suggest a few links if you are just starting to look into it:
Either way, there are 3 key concepts involved in this prototype:
1. Captured images are stored directly in Dynamics in a multiline text field
You might say this is not optimal, and I would agree. But that takes away the need to figure out where to store those images, and, at the same time, allows me to display such images in the Word Template (see this link btw)
Here is how the field is defined:
What if I wanted to store file data somewhere else? Technically, the problem is not so much where to store it, but whether I can easily use those stored images in the Word Template (or in the SSRS report), since, in the end, I’ll need to produce a printer-ready “photo id”. Either way, at this point I did not want to mess with Sharepoint (have a look here: https://blogs.perficient.com/2018/10/08/store-powerapp-camera-photos-in-sharepoint-or-onedrive/ ), so I figured I’d take the easy route.
2. There is a Word Template that’s using that field
That’s pretty straightforward – page size is set to match standard ID width/height, there are no margins, and that picture content control is linked to the new_imagedata field
3. There is a Canvas application that’s embedded into the contact form
I am assuming you know the basics of creating an embedded canvas app by this moment (if not, have a look at those links above), so I’ll spare you from those details.
Here is how the app looks like:
All initialization happens in the Timer1.OnTimerEnd. This is where ContextPicture is initially set from the new_ImageData field, and, also, where SelectedContactId is initialized with the ContactId:
Camera control is set up with the stream rate – this is to use a button to capture images (rather than to do it through Camera OnSelect):
PictureButton is there, but it’s right under the “Open Camera” button (don’t be confused with how it looks like on the screenshot) – this button will set ContextPicture from the camera stream, and it will hide the Camera:
OpenCamera button will display the camera:
Image1 will be displaying ContextPicture:
Finally, depending on whether the camera is visible or not, Image1 control and those 3 buttons will change their visibility as required. For example:
That’s about it. In other words:
How does it work with the “Save” button, though? Here is a screenshot:
As I mentioned in the other post (see those links above), when working with the Base64 images in the Word Templates, I have to remove that data:image.. prefix. That’s exactly what Substitute function is for. And, then, there is a Patch function that’s updating a record in the Contacts data source. I have added that one to my canvas app separately so I’d be able to update the contact record.
And that’s about it.. Once the picture has been taken, I just need to download the template:
Then open the document and send it to printer.. Here we go:
One last bit – you may want to consider setting Camera->DisplayMode property depending on whether the Camera is visible or not. Otherwise, the camera just goes on and stays activated till the app is closed:
Business Applications communities