Creating a seamless user experience in a SharePoint integrated Power App (Canvas App) can be challenging, especially when performing actions after form submission. Once a form is submitted, it closes, but the OnSuccess property allows you to run code post-submission.
In this blog, I’ll show you how to use the OnSuccess property to make changes to the newly created SharePoint item. Although you can’t use ThisItem or link directly to data cards, I’ll guide you through the process to ensure your app functions smoothly.
By the end, you’ll know how to enhance your Power App’s functionality and improve user experience. Let’s dive in!
Create a SharePoint list
Create a SharePoint list on any SharePoint site.
Add 1 text column named OnSuccesData.
Create the SharePoint integrated power app.
Open the created SharePoint list.
Click on Integrate, Power Apps, Customize Forms app.
This will create a basic SharePoint integrated power.
Remove the Attachments DataCard.
Click on the SharePointForm1 and add a custom datacard.
Add a label and a Text Input objects on the datacard.
Rename the label to lbl_OnSuccesData.
Rename the Text Input to txt_OnSuccesData.
Set the OnChange to the following code.
We need to store the Text value in a variable, because when you call directly for txt_OnSuccesData.Text it will work for editing items but not for creating items.
Set(varOnSuccesData, txt_OnSuccesData.Text);
Set the 2 objects below each other.
Set the text of the label to On Succes Data.
Set the Default of the text input to “”.
Create a new blank Power Automate flow from the power app.
Name the flow to Actions after submission.
Set the following text inputs.
ItemID
OnSuccesData
Add the SharePoint action Update item and set it for the earlier created SharePoint list.
Set the Id to ItemID from the power app.
Set On Succes Data to OnSuccesData from the power app.
Save the Power Automate flow.
Open the Power App again.
Select the OnSuccess property of the SharePointForm1 object.
Add before the ResetForm(Self); code the following code to start the Power Automate flow.
In today’s fast-paced business environment, leveraging automation and artificial intelligence (AI) is crucial for maintaining efficiency and gaining insights. This blog post explores how to create a Power Automate flow that reads emails with attachments, extracts content from images or PDF documents using AI, and can perform various analyses on the extracted text. For instance, you can determine the sentiment, generate summaries, or classify emails as purchase requests or complaints and routing then accordingly. By integrating these advanced technologies, businesses can streamline their processes, enhance decision-making, and stay ahead in the competitive landscape.
AI Generated image
Create an AI model
First, we need to create a custom AI document model or AI Prompt that receives the PDF content and analyses it. But off course we can also use a default model. In this example we will be using the default AI Sentiment.
Create a Power Automate Flow
In this flow we will get all the attachments from the email and get the content ready to be sent for a sentiment analysis.
Create a Power Automate flow with the trigger, When a new email arrives in a shared mailbox (V2).
Connect this with the required email box and select the option Include Attachments to Yes.
Add the action Initialize variable and call it Initialize variable – Attachment Content.
Add a Scope action called Scope – Get PDF Content.
We are going to combine all the content of all the found PDF attachments into one variable. You could also send each attachment file separately.
First, we need to filter the attachment files to only get the PDF file.
Add a Filter Array action and call it Filter Array – Attachment for PDF.
Set the from to Attachments.
Set the first value to Attachment Content type.
Set the filter to is equal to.
Set the second value to application/pdf.
Add an Append to string variable action and name it Append to string variable – Attachment Content.
Set the Name to Attachment Content.
Set the Value to Content (from the filter array) – .
An apply to each will be automaticallycreated, name it Apply to each – Found PDF.
Add a Recognize text in an image or a PDF document below the apply to each.
Set the image to Attachment Content.
Add a Scope and name it Scope – AI Sentiment.
Add a Create Text with GPT using a prompt action and name it Create Text with GPT using a prompt – Get sentiment.
Leveraging AI for email management not only saves time but also reduces the risk of human error. By automating the evaluation process, businesses can ensure that important emails, such as orders, are promptly and accurately identified, allowing for quicker response times and improved customer satisfaction. Embracing AI in email workflows is a smart move towards greater productivity and operational excellence.
In this article, I explain how to create an AI prompt model using Microsoft GPT to streamline email processing. By integrating Power Automate, the flow sends the content of each new email to the AI model, which then determines if the email is an order. If identified as an order, the AI responds with a JSON output indicating a positive result. This approach enhances the efficiency and accuracy of order processing through intelligent automation.
Create an AI model
For this blog I create a simple AI prompt to evaluate if a incoming email is a request for an order. The actual prompt is more complicated but confidential.
Open the AI hub aka AI Builder and select the Create text with GPT using a prompt.
Give the prompt a name.
Create three input parameters.
Email
EmailSubject
Attachments
Select by Output JSON (preview) and click on Edit.
Add the following JSON code.
{
"Order": "true"
}
Set the Model to either GPT 3.5 (cheaper but less accurate) or GPT 4 (more expensive and more accurate).
Set the Temperature to 0.
Set the Prompt as follows or make your own prompt.
Save the prompt.
Create a Power Automate Flow
The Power Automate flow will start for every incoming email and will send to the AI model, the email body, subject and names of the attachments. The model will return its determination in JSON form.
Create a new Power Automate flow with an outlook/email trigger, When a new email arrives in a shared mailbox.
Add an Initialize variable action to create a variable called All attachment names.
Add an Append to string variable and select by the name the All attachment names variable.
Set for the value the attachments of the email, with the following code. This will automatically add a Apply to each action.
items('Apply_to_each_-_Attachment')?['name'] -
Add the Create text with GPT using a prompt action.
Select your created AI Prompt.
Set by attachments the variable All attachment names.
Set by Email the Body of the email.
Set by EmailSubject the Subject of the email.
This will start the AI model and it will return its results to the flow.
Form here on you can add in the requered steps for your specific process and test the process.
In a recent AI project, I developed a solution to evaluate every incoming email in a shared mailbox using an AI model (GPT with prompt). To inform users of the shared mailbox that an email has been processed, the email is flagged with a custom Outlook category. This process leverages a special HTTP action for Outlook, simplifying the implementation. Notably, there is no need to set up any special permissions if the flow owner already has access to the shared mailbox. This example does not cover the specifics of communicating with the AI through Power Automate.
Creating custom category in Outlook
Open Microsoft Outlook.
Click on Category in the Home Ribbon.
Click on All Categories.
Click on New.
Set a name and select a color.
Click on OK followed by Clicking on OK.
You have now created the custom Outlook category.
Setting the category with Power Automate
Create a new Power Automate flow with an outlook/email trigger. For example: When a new email arrives in a shared mailbox.
Bing maps has been an easy-to-use solution for getting location information in canvas apps, but this offering will be placed under the Azure Maps umbrella. While Bing Maps will continue to function for now, it’s essential to prepare for the transition. In this blog post I will explain how to use Azure Maps in a Canvas App. Please note that the locations shown in this post are not my actual location.
Azure Maps Services
First, we need to create a Azure Maps Account in a resource group (I will presume you know how to create a resource group).
Open your resource group.
Click on Create and search for and click on Azure Maps.
Click on Create.
Give the Azure Maps Account resource a name.
Select the correct Region and Pricing tier.
Agree with the terms and click on Review + Create.
Click on Create and wait for the deployment to be ready.
Click on Go to resource.
Click on Authentication and copy the Primary Key. You will need this in the Power Automate Flow.
The Power Automate Flow
Create a new Power Automate Flow and name it Azure maps get Postal Code.
Add as the trigger Power Apps (V2), with two text inputs called Longtitude and Latitude.
Next, we will add a HTTP action, this will call Azure Maps to get the location details based on the provided GPS location.
Set the method to Get.
Set the URI to the following code, make sure to put in your subscription-key (that is the primary key from the Azure Maps Account resource).
Set the Latitude and Longitude with the input fields form the trigger.
Add an output text called postalcode and add the compose as its value.
Your flow will now look like this.
The canvas app
We will now create the canvas app with a map that shows the user’s current location on a map, and a button to get the postal code of that location and a reset button. Please note this is not my actual location.
Create a new canvas app, I blank Phone canvas.
Click on Power Automate followed by Add flow to add the earlier created flow.
Add the map element to the canvas app.
Set the DefaultLatitude property with the following code.
Location.Latitude
Set the Location.Latitude property with the following code.
Location.Longitude
Set DefaultLocation property with the following code.
true
If you want to see your Latitude and Logitude you can add labels to display the values.
Add a Label and set the Text property with the following code.
"Latitude: " & Location.Latitude
Add a Label and set the Text property with the following code.
"Longitude: " & Location.Longitude
Add a button and set the Text property with the following code.
"Get postal code"
Set following code on the OnSelect property. If needed update the code with your flow name, I used AzuremapsgetPostalCode.
In today’s digital age, businesses are constantly looking for ways to streamline their processes and improve their customer experience. One way to do this is by leveraging the power of chatbots, which can quickly and efficiently answer customer inquiries. In this blog post, we will explore how to create a canvas app that uses Power Automate flow to ask ChatGPT API questions and display the response in the canvas app. By the end of this tutorial, you will have the tools and knowledge to build your own chatbot app that can answer your customers’ questions in real-time, enhancing their overall experience and increasing your operational efficiency. So, let’s get started!
In my previouse blog post I explained how to automatically create and delete B2C account for Dataverse Contacts. In this post, I will dive deeper into the process by automating the redemption of an invitation code process. By default, new contacts need to redeem an inventation code before they can access the Power Pages. I am using the one-time-password setup for access to the Power Pages and for ease of use I don’t want the contact (external users) to have to redeem an inventation code.
To achieve this, we will automate the process by granting the contact a web role, connecting the B2C account ID, and adding the external identity. This will allow the contact to access the Power Pages without having to redeem an invitation code.
Today, we’ll be discussing a crucial aspect of B2C account management – the creation and deletion of B2C accounts in response to changes in the Dataverse Contact. This is an important topic for businesses that deal with external Power Pages user (contacts) that want to ensure the security of their records and Power Pages. In this post I will explain how to create or delete B2C accounts that are connected to a Dataverse Contact. So, let’s dive in!
Create a B2C account when a Dataverse Contact is created
Whenever a new contact is created a new B2C account needs to be created automatically that is linked to the contact. This is done thought the email address of the contact and the Azure B2C account id. These automations will limit the amount of manual admin work.
Create a new Power Automate flow with the name Create B2C user for Dataverse Contact.
Add the Dataverse trigger When a row is added.
Set the Change type to Added.
Set the Table name to Contacts.
Set the Scope to Organization.
Create the following 3 variables.
You will need to create an Application Registration in the B2C tenant with the following permissions.
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
User.ReadWrite.All, Directory.ReadWrite.All
Delegated (personal Microsoft account)
Not supported
Application
User.ReadWrite.All, Directory.ReadWrite.All
Store the Client ID, Tenant ID and Secrect in the corresponding variables.
Add a HTTP action called HTTP – Delete User to the flow.
Set the Method to: Post.
Set the URI to the following code.
https://graph.microsoft.com/v1.0/users
Set the body to the following code.
In my scenario the user will not be using the password but the one-time password from B2C. That’s why I have added a guid twice as the password.
This call will create an account of the type email address which allows for any valid email to be used. The email does not have to be part of the B2C domain.
Parse the JSON response of the HTTP – Create User call.
Add the Dataverse action Update a row.
Set the Table name to Contact.
Set the Row id to the contact id of the trigger.
Add the id that was returned by the HTTP call that created the B2C account.
Save the flow.
Delete B2C account when Dataverse Contact is deleted
In my scenario I am maintaining the Power Pages contacts within a canvas app, and when a contact is deleted the associated B2C account needs to be deleted too.
Create a new Power Automate flow with a Power Apps (V2) trigger with the name Delete B2C users for deleted Dataverse Contact.
Add an input Text field names ActiveDirectoryID.
This is the Object ID of the Azure B2C Active Directory User connected to the Contact.
Create the following 3 variables.
You will need to create an Application Registration in the B2C tenant with the following permissions.
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
User.ReadWrite.All
Delegated (personal Microsoft account)
Not supported
Application
User.ReadWrite.All
Store the Client ID, Tenant ID and Secret in the corresponding variables.
Add a HTTP action called HTTP – Delete User to the flow.
Set the Method to: Delete.
Set the URI to the following code.
https://graph.microsoft.com/v1.0/users/
Add the PowerApp (V2) parameter ActiveDirectoryID to the end of the URI.
Set the Tenant, Client ID and Secret fields with their corresponding variables.
Set the Authentication to Active Directory OAuth.
Set the Audience to the following code.
https://graph.microsoft.com
Save the Power Automate Flow.
Open or create a canvas app (Power Apps).
Open the Power Automate panel in the canvas app.
Add the Delete B2C users for deleted Dataverse Contact Power Automate flow.
Add a gallery with the source set to the Dataverse Contact table.
Add a recycle bin or other delete Icon to the gallery.
Add the following code to the recycle bin icon under OnSelect.
This will remove the contact record.
Starts the Power Automate Flow and sending the User Name (Users B2C object ID).
When sharing information or sending out a notification on teams I like to use the adaptive card feature. Adaptive Cards are the Teams method of sharing and displaying blocks of information in an easy-to-read manor without the complexity of customizing CSS or HTML to render them. With adaptive cards you can even create polls, show weather information, and create hyperlinks.
Creating a feedback form
Create a Power Automate flow with the required trigger.
Add the Post adaptive card in a chat or channel Teams action.
Select the Group chat (Channel or Group Chat) or provide the chat ID.
Add the following JSON code for an example feedback form with a title, single line, and multi-line text input fields and two types of choice list.
When managing multiple Power Automate Cloud Flows it can easily become a big task to figure out what went wrong and where. My client has more than 10 Cloud Flows that run multiple time per day or per hour. The solution is to create a log table (dataverse) or list (SharePoint) where all the runs are stored. The log table contains all the data an administrator needs to maintain the Cloud Flows. In my example I create a Dataverse table.
The Dataverse log table
In the log table we store the following data.
The Cloud Flow
In every Cloud flow a try and catch scope is added. All the main actions are in the try scope, if one of these actions fails than the catch scope will be used.
Add a Scope with the name Try.
Add the action the Dataverse Add a new row action.
Select the log table by Table name.
Select the Log status Processing, I use Processing, Failed and Successful.
Add the Cloud Flow name to Process name.
Add the following code to the Environment field.
workflow()?['tags']?['environmentName']
Add the following code to External URL, use the code snippets for the fx code. This creates a link to the actual flow run.
workflow()?['tags']?['environmentName']
workflow()?['name']
workflow()?['run']?['name']
Set the Status Reason to Active.
Add the end of the try scope add the Dataverse Update a row action.
Select the log table by Table name.
Add the ID of the create log in the Row ID field.
Select Successful in the Log status field.
Add a Scope with the name catch.
Add the Filter Array action.
Add the result of the try scope in the From field.
result('Try')
Add the following filter Status is equal to Failed
item()?['status']
Add the Dataverse Update a row action.
Select the log table by Table name.
Add the ID of the create log in the Row ID field.
Select Failed in the Log status field.
Select Inactive in the Status field.
Add the following text to the Log details: Flow log action(s):
Add the following code to the Log details, to show the error message from the try scope.