PowerApps

How to upload Powerapps Audio into sharepoint?

Problem: Recently I have a requirement to upload recorded audio from powerapps to sharepoint.

Requirements seems to be straight forward if you have a basic knowledge of Powerapps and Microsoft flow isn’t it? But there is a catch (let’s see that in sometime :-))

Just for the completeness of this blog, I will reiterate certain Hows.

How to Record and listen the Audio in powerapps?

In powerapps we have a media control named MicroPhone to record the audio, and another media control named Audio to listen to the recorded audio.

Further on how to do that:

In the Microphone control (I named as MyMic) Onstop property collect the recorded audio as follows:

ClearCollect(collInspectionAudio, MyMic.Audio);

In the Audio Control Media property, place the collection which you have used to collect the recorded audio earlier as follows:

First(collInspectionAudio).Url

We now know how to record and listen the audio within powerapps. Now lets discuss the actual challenge on how to upload it to sharepoint.

Analysis

We use Microsoft flow to upload to sharepoint however in my microsoft flow it looks straight forward to pass the audio as First(collInspectionAudio).URL to my sharepoint file content as shown below.

when I execute the Powerapps and hence my flow it is creating an audio file in my sharepoint, however its not playing. when I see the outcome of the Flow i found it strange because File content looks as below:

When I further drilldown into the problem by checking the datatypes in flowstudio. I realized that in Createfile action of Sharepoint connector expects Binary format hereas powerapps send its audio content in byte format.

Solution:

So the only way to get around is accept Byte parameter from Powerapps and use it to upload file in sharepoint.

For that, I used Outlook connector  to send an email. When I ask for attachment parameters in powerapps it can send in byte format.

Note: If you have a requirement to send email of the audio file along with uploading in sharepoint then that’s amazing. If you don’t have such emailing requirement then another slight hack is required.

  1.  Create a condition which never becomes true. (in my case 100 equals 200 which never becomes true ;-))
  2. In the true section call Outlook connector and ask for parameters for Attachment Name and Attachment Content.
  3. In the false section call Sharepoint Connector and create a file by using same parameters which we have in Step 2.

Final working Microsoft Flow looks like this:

Warm Regards,

Pavan Kumar Garlapati

 

 

Want to auto-tweet ? Here’s a way to do it with a Flow

I figured this one was valuable enough to copy over here 😉

As per my recent blogpost.

While I’m away

The trigger for this post is simple.. I’m heading into a well deserved summer vacation where I want to remain active in some of the social medias while being able to just relax and enjoy life!

So, I figured that building an automated Flow which would capture tweets of interest (based on keyword search) and then retweet them out with a specified delay could well do the job!

This would allow me to put content in my feed, adding value to the original tweets by issuing my message later on, thus maybe appearing on someone’s radar who would not have caught the original post.

Issue

The twitter connector, as of now, doesn’t offer an action to retweet nor does it allow to include direct references to users / authors (@xxx). So in order to point back to the original post I had to build the twitter URL to it. I also included a signature note where I thank the author and notify the readers of this issue.

I’ve added this functionality as one of my project goals. Creating a custom connectors will probably allow me to resolve this. Right now, no time, so let’s just do it in a quick and dirty way and solve this out when I’m back on the saddle after drinking all the margaritas in the world 😉

Flow

Overall, here are the core functions that my Flow will execute:

  • Act on tweets that use predefined keywords, for example:
    • #powerapps
    • #powerplatform
    • #poweraddicts
  • Only process original tweets (I don’t want to overflood the feed by considering RTs)
  • Only process other people’s tweets (that’d be kind of awkward if I’d process my tweets)
  • Manage and process French and English tweets only
  • Keep track of the tweets I re-posted as a reference for later BI / processing

Prerequisite

Since I want to have a log of the tweets I posted with the references to the original post as well as the posted message the Flow generated, I created an entity in CDS.

Flow details

  • Trigger: Twitter – When a new tweet is posted

  • Criteria: set the Search text criteria to
    • #powerapps OR #powerplatform OR #microsoftflow OR #poweraddicts”

  • Initialize variables required in the flow
    • baseMsg : the new message to post (based on the language of the original tweet)
    • linkToTweet : the URL to the original tweet
    • proceedTweet : Boolean flag to allow to stop the Flow if not a supported language

  • Only proceed on original tweets (if RetweetCount = 0)

  • Only proceed with tweets from other authors (if TweetedBy is not equal to ZePowerDiver)

  • Look for tweets in French to adapt the message accordingly (if TweetLanguageCode = fr)

  • Assemble the message and assign it to the baseMsg variable
    • insert the linkToTweet variable for the URL to the original tweet
    • insert the User detail’s full name (Original tweet user full name)
    • insert their tagname too (Tweeted by)

  • If not in French, then validate if it’s in English (if TweetLanguageCode = en)

    • If so, assemble the message and assign it to the baseMsg variable
      • insert the linkToTweet variable for the URL to the original tweet
      • insert the User detail’s full name (Original tweet user full name)
      • insert their tagname too (Tweeted by)

 

  • Otherwise, set the proceedTweet variable to false so the post will not be processed at next step

  • at the outcome of the previous steps, validate that proceedTweet is still True

  • if we can proceed, then inject a delay of (n) hours, as per your preference, then post the tweet using the baseMsg variable as the Tweet text
    • For the injection of the delay, the calculation is based on current time as follow:
    • addHours(utcNow(),1)

  • Last step is to insert a new record in my CDS entity to track history

Last minute modifications

After testing the flow, letting it run for a while I made a few adjustments to ensure the posted tweet would be of a maximum of 280 characters, otherwise an error is thrown by the connector.

  • First modification: I added a call to bit.ly to generate a shorter url to the original tweet

  • Second modification: I shortened the baseMsg in both languages to be right to the point nothing more

  • Third modification: as a safety net, I applied a substring function to the baseMsg variable submitted to the Twitter action
    • substring(variables(‘baseMsg’),1,280)

And then the failure!

After implementing those last minute changes I looked back at the generated tweets and noticed that the preview feature that you normally get with the embedded links disappeared!

So, to quickly resolve this, I’ve removed the bit.ly part of the connector, but left the substring part.

Next step

To resolve the constraints regarding the RTs and tagging, which are due to anti-spam rules from twitter, I will attempt to follow Tomas Poszytek’s blog post (that I’ve seen on my twitter radar yesterday while finishing up the details of this article)

Keep on diving!

PowerApp Admin Tools

I’ve been working on XrmToolBox Tools for a bit now, both speaking and posting on the huge number of cool tools and how we can build our own. I’m still working on a few XrmToolBox related projects, but when I started diving into Power Apps, I immediately wondered if I could replicate some Tools in Canvas or Model Driven Apps. Wouldn’t it be cool if we could build out a suite of some administrator or developer tools as Power Apps?

In my post Building XrmToolBox Tools, Part 2, we build an example Tool that allows admins to view the list of Users with a Security Role assignment. It’s a relatively simple tool but it can be pretty useful if you need a quick check on a Role for migrations, troubleshooting, etc. This seemed like as good a candidate as any for a new ‘Admin Tool’ Power App.

Security Role Member Manager!

The proposed functionality for the tool is pretty simple: provide a list of Security Roles in the system, and when the user selects a Role, show the list of assignments. This was meant to be written in about an hour, so that was the extent of the capabilities. Since we have a bit more time, we can add some features. How about we display the list of Teams that have the selected Role assignment and allow Adding or Removing a User or Team to the selected Role.

These requirements are a pretty good candidate for a Canvas App. We can build this using the following components:

  • Common Data Service (CDS) connector – provides the list of Security Roles
  • Office 365 Users Connector – provides the user picture
  • Gallery – bound to the Security Roles list
  • Gallery – bound to the list of Users related to the Security Role
  • Gallery – bound to the list of Teams related to the Security Role

The main screen layout and functionality is also fairly simple. Bind the main grid to to the Security Roles list, and on the select event, bind the secondary lists to the related Users and Teams. No real code behind, just some simple data binding to galleries.

Here is the initial main screen for the Power App:

Security Role Member Manager

Some challenges, some solutions

With the XrmToolBox Tool, I wrote some code to retrieve Security Roles and and User Security Role assignments using the standard SDK Query Expression methods. The list of Security Roles was a simple Retrieve Multiple while the User Role Assignment is a many-to-many relationship.

The many to many is where I stumbled a bit. When I select my Security Role, I want to retrieve the Users and Teams which are both many-to-many relations to Security Roles. The CDS connector does not list the join table as an Entity, so I couldn’t simply add a new Data Source for User or Team and filter by the selected Role. Fortunately, support has been added for many-to-many relationships in the CDS connector. Here is an excellent blog post on the feature by Greg Lindhorst, Principal Program Manager at Microsoft: Relate records in Many-to-Many relationships

So to render the list of Users and Teams, I can bind the galleries using a simple formula. The main screen gallery from which you select a Security Role is named ‘Security Roles List’. So the User and Teams gallery Items property can be set using these simple formulas respectively:

'Security Roles List'.Selected.Users
'Security Roles List'.Selected.Teams

As you can see in Greg’s post, adding and removing Users and Teams are fairly easy too. To remove a User from the selected Security Role, we need a single line formula added to our gallery button:

Unrelate('Security Roles List'.Selected.Users, ThisItem)

That statement passes the selected Security role and the currently selected User to the Unrelate formula, and we’re done!

Next Steps

I plan on a follow up post with a bit more functionality. For example, I like the inline model for selecting a User shown in the post by Greg above, but I think selecting multiple Users and Teams works better. Another nice feature will be to distinguish between Business Units. Right now, this pulls all Security Roles for the entire organization.

This sounds like an obvious one, but I also plan on adding a confirmation dialog before removing the User or Team from a Security Role. This was a bit more complicated than I had expected, so I will write up more detail on how this will be implemented.

As I was working on this sample Power App, I came across a great post User Admin PowerApp (Part 4) by d365Cooky that proposes a similar tool, but for managing Security Roles for a selected User. I like the idea of embedding this into Dynamics 365 CE. By the way, I saw the link via Guido Preite’s dynamicsweekly.com newsletter. If you have not already signed up for this, get to it!

I’ll post notes on all these updates with more detail on how it was built, including the full solution for download in a follow up post.

Powerful stuff!

I feel like I have said that a LOT recently! In a relatively short time, I built a functioning Power App that will allow administrators to manage the Security Role Users and Teams. I put this together in a few hours, including some reading on the CDS connector capabilities and designing a few screens. All of this was done using the existing connectors and no custom code outside of the standard Canvas App formulas.

This is not as complex a tool as you may find in the XrmToolBox, and I am definitely going to continue any contribution I can to the XrmToolBox! But I think this once again demonstrates how the Power Platform allow us to provide low code/no code solutions to your users.

In the meantime, as always, any comments, suggestions, or questions are appreciated!

Dynamics 365-CE Approval Dialogues Using Canvas-apps

There are scenarios where we need to configure approvals in Dynamics 365, for example, mark an account as a premium customer after approval or qualify leads after approval etc. We used dialog control to capture approval request and comments but, now dialog controls are depreciated and not advised to use for new projects.

As per Microsoft’s initial announcement

Dialogs are deprecated and are replaced by mobile task flows (available as of the December 2016 update), and business process flows. Both task flows and business process flows will continue to evolve to make the transition easier.

But either tasks flow or business process flow was not a perfect replacement for Dialog. Knowing this pain from users, Microsoft has now modified the announcement.

Dialogs are deprecated, and should be replaced by business process flows or canvas apps

Even though I knew canvas apps can be now embedded in model-driven apps, I hadn’t thought of this option until I came across this new announcement, so tried replicating my approval dialogues with a canvas app and it works fine. Pheww!!!! 🙂

For testing purpose, I replicated the dialogue for creating approval request for the Account entity.

  1. created a canvas app to create an approval request.
This sample app changes account status to pending verification and captures the comments in one custom field.

2. Now we need to call this app from account form, obtain the app ID from app details section.

select app details to get the App GUID

3. I need to call this canvas app as a popup when the user clicks a button. I created a custom button for account entity-> added a JavaScript as button action to call an HTML web-resource and embedded my canvas app in this HTML I-frame.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<html><head>
<title>Approval</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body style="padding: 0px; font-family: arial; overflow-wrap: break-word;" onload="LoadPowerApp()">
<center>
<iframe id="Approval" width="800" height="600"></iframe>
</center>
<script id="myScript">
function LoadPowerApp()
{
var AccountID = window.parent.opener.Xrm.Page.data.entity.getId().slice(1, -1);
document.getElementById("Approval").src=url;
}
</script>
</body>
</html>

I know you have many questions now. "https://web.powerapps.com/webplayer/iframeapp?source=iframe&appId=/providers/Microsoft.PowerApps/apps/56123673-f45c-4b96-b9e6-ece1b0a8069a&ID="+AccountID;

This is the key and I will breakdown it into parts “https://web.powerapps.com/webplayer/iframeapp?source=iframe&appId=/providers/Microsoft.PowerApps/apps/APP GUID&CUSTOM PARAMETER NAME=”+PARAMETER VALUE

App GUID I explained in step 2, now regarding a custom parameter, I deliberately didn’t mention it when we discussed the app creation and kept for this section. When we open this canvas from an account form(like we start a dialogue) the app needs the record GUID to update the account status

I have used form control in the canvas app and filtered the item using the ID Parameter.

4. Now try your button and you can see the magic.

You can download the sample APP from TDG Power Apps bank.

Please note this is a basic app I tried for testing purpose and needs many improvements to use in a live project. you are always welcome to discuss with on this app.

Hope this helps….. 🙂

Set canvas PowerApp date to the last day of the month

When working with canvas PowerApps, you may have a need to have some date ranges set by default. A typical scenario might be where you have 2 date filters and you want to show records that occurred between those date ranges. A scenario I had to work with recently was where the customer required the default filter dates to be the first day of the current month and the last day of the current month.

Setting a date to the first day of the month is relatively straight forward. Using a combination of the Date and the Now functions, you can set up your first day of the month variable as follows:

Set(varStart,Date(Year(Now()),Month(Now()),1))

The tricky part is getting the last day of the month. How do we know if its got 30 days or 31? What about the month of February?? What happens in a leap year!?
Turns out there is a handy undocumented “feature” when you use the Date function. If you set the day property to the number 0, it would return the last day of the previous month. So if I wanted to get the last day of February for example, my function would look as follows:

Set(varEnd,Date(2019,3,0))

Binding that variable to a date control I had, I was able to get the last day of February accurately!

date

Hope this helps.

PowerApps Licensing Cheat Sheet

During the App in a Day sessions I’ve held there were often questions regarding the types of license that is required, based on the options/features that are part of the built solution. Based on the fact that an image is worth a thousand words, here’s how I’ve been able to easily demonstrate the basic differences between Office365 license, PowerApp P1 and P2 licenses. It’s not about all the nitty gritty details, but the base is there. In doubt always refer to Microsoft’s official documentation!

 

Quick Tip: How to Make Gallery Image Clickable

I stumbled upon a question in the PowerApps forum on how to make Gallery items clickable so I tested it out and found that it can be achieved very easily..

Steps:
1. Create a gallery and bind it to Account entity in CDS..
2. Bind your Gallery to table with with a field that stores hyperlink. In this case I bind it to Account entity and field by the name of Website.
3. Select a text,label or image in the Gallery Item. On the On Select property, enter the following command

Launch(ThisItem.website)
(Substitute website with the field that stores the URL)

In this case, I entered it on the Image.

4. Click save and Publish.

Now on the app, when I click on the image, it will redirect me to the website stored against the hyperlink.

Click to Watch

Happy Power-Apping!

Wave 2 Release Plan with the MVP’s Part 2

Part 2 of our MVP review of the PowerPlatform 2019 Wave 2 Release Plan. In this episode I am joined by Mark Christie, Iain Connolly, Andrew Bibby, and Shawn Tabor to discuss:

  • Field Service
  • Unified Interface
  • Canvas Apps
  • Microsoft Flow
  • Common Data Service
  • The death of Task Flows

And in case you missed it, catch part 1 here.

PowerApps for the CRM Person 1: Showing related entity data

If you are like me and have worked with Dynamics 365/CRM for years, approaching PowerApps might be a little bit intimidating. Part of it is that so many things that are very easy or automatically done for us in Dynamics 365 and model-driven apps need to be manually done in canvas apps. And when you search for the answer, much of the PowerApps blog and video content is from the perspective of a developer with a non-CRM background, like SharePoint.

In this series of posts, I intend to show how to do some of these things that are common in Dynamics 365 when making a canvas app. If you don’t have a Dynamics background, hopefully you will also find some benefit from them.

Related Entity Data

When building a more complex app, you frequently have the need to work with parent/child data. Say you have companies and want to show the employees working for the company, or an event and related registrations for the event.

In Dynamics and model-driven apps, this is easy.

Every record form shows a Related tab where you can see all of the entity relationships.

We can also add a subgrid to the parent entity form to display related records in-line.

Related Entity Data in Canvas Apps

When making a Canvas App, the maker needs to add visibility of related records to the app. In this example, I’m building a canvas app for a volunteer coordinator to use to manage a disaster relief team.

First, add a data connection to each table/entity that you will include in your app.

Once you have your data connections, now you can display your related entity data in your Canvas App.

Option 1: In-line

In my app I want to show skills on the person form, similar to the experience of a subgrid in Dynamics 365. That way I can easily see the skills related to a person.

In this case I add a display form and a gallery to the same page of the app

The display form displays the selected person from a person gallery on another page of the app. The skills gallery is connected to a cross-reference table of people and related skills.

This gives users of the app a subgrid-like experience in a canvas app. Note if you want to give users the ability to create child records from the subgrid gallery, you will need to add that to your app. To do this, I added the + icon to the subgrid header, and in my expression, set a context variable on the next screen with the ID of the selected contact. This allowed me to automatically set the created person skill to Barbara.

 

Option 2: Related page

Sometimes you don’t want to show the related information in a subgrid. Maybe your form is more information dense and you just want to go to a full list of record. This behavior is easy to reproduce with a Canvas App. In our scenario, volunteers will send updates from the disaster site about what they have done. In my app, I already have a page that users can go to see all updates from all teams.

The Update gallery has a search text input control to search and filter the update list.

We can leverage this same page for display of related records:

  1. Set the default value of the search input textbox to a context variable.
  2. From the parent record page, add a button or icon to navigate to the related records, in the navigate formula update the context variable referenced in the search control.

Now when volunteers click the update button from the disaster page, they see a filtered list of only the updates for the selected disaster.

Wrapping up

So is it easier to display related entity data in model-driven apps? Yes. However, once you get used to working with canvas apps and filtering galleries, you will appreciate the extra level of control that you have over the experience, and can easily display related records in your canvas app.

How to Enable the PowerApps AI Builder

Hey, Will here – just a quick post. I’ve had quite a few people come up to me asking how to enable the new “AI Builder” for Power Apps on their environment – which strikes me as slightly strange as it comes enabled as default. However, here is how you do it.

 

  1. Go to: https://admin.powerplatform.microsoft.com/ 
  2. Then using the navigation pane select “Environments” then select the environment you wish to turn the ‘AI Builder’ on for:
  3. Then select “Settings”:
  4. Then select “Features”:
  5. Then enable the PowerApps AI Builder:

Now go forth and build something AWESOME!

Review the Power Platform release plan with mvp’s

In case you missed it, the 2019 wave 2 release plan for Dynamics 365 and the Power Platform was released today.  You can read James Phillip’s blog summary at https://cloudblogs.microsoft.com/dynamics365/bdm/2019/06/10/announcing-new-features-growing-demand-for-dynamics-365-and-power-platform/ and you can download the full release notes from https://docs.microsoft.com/en-us/dynamics365-release-plan/2019wave2/.

This afternoon, I was joined by MVP’s Megan Walker, Ulrik Carlsson, and Andrew Bibby to review the release plan. Watch the video below.