Power Platform: Enhancing SharePoint Integrated Power Apps with Post-Submit Actions

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.
Actionsaftersubmission.Run(SharePointForm1.LastSubmit.ID, varOnSuccesData);
  • Test your app by putting a text in the title and a text in the second On Succes Data text input object.
  • After you save the form, the flow will start and store the On Succes Data in the SharePoint on success data column.

Power Platform: QR Codes in a Canvas App

Creating QR codes in a canvas app can significantly enhance user experience by providing quick access to links and information. QR Codes are the way to go if you want to share a link from a canvas app. In this blog, I will explore two efficient methods to generate QR codes: using the QR Code connector and an open source API, both options use the goqr.me API endpoint. These approaches will help streamline the process and offer flexibility in implementation, catering to various business needs. 

Methode 1: Using the QR Code connector

This method utilizes the GoQR (Independent Publisher) connector available in Power Apps to generate QR codes effortlessly.

  • Create a new blank canvas app.
  • Click on the Data tab and search for QR Code.
  • Click on the GoQR (Independent Publisher).
  • Then click on GoQR (Independent Publisher) to add the connection.
  • Add a Text input.
  • Add a button, name the button Create QR Code.
  • Set the OnSelect of the Create QR Code button to the following code.
Set(QRCode, 'GoQR(IndependentPublisher)'.Create(TextInput1.Text))
  • Add another button, name the button Reset QR Code.
  • Set the OnSelect of the Reset QR Code button to the following code.
Set(QRCode, Blank())
  • Add an image object.
  • Set the image property to the following code.
QRCode
  • Type an URL in the text input and click on Create QR Code to generate the QR Code.
  • Click on the Reset QR Code button to reset the QR Code.

Methode 2: Generating QR Code via a direct API call

For users who prefer a more direct approach, it is possible to call the goqr.me API directly from Power Apps. This method is flexible and does not require adding a connector.

  • Create a new blank canvas app.
  • Add a Text input.
  • Add a button, name the button Create QR Code.
  • Set the OnSelect of the Create QR Code button to the following code.
    Make sure the name of the text input is correct.
Set(QRCode, "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" & TextInput2.Text)
  • Add another button, name the button Reset QR Code.
  • Set the OnSelect of the Reset QR Code button to the following code.
Set(QRCode, Blank())
  • Add an image object.
  • Set the image property to the following code.
QRCode
  • Type an URL in the text input and click on Create QR Code to generate the QR Code.
  • Click on the Reset QR Code button to reset the QR Code.

Power Platform: Analyse email attachments with AI

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.
  • Set AI Sentiment as the Prompt.
  • Set Input Text to Attachment Content variable.
  • Your flow now looks like this.

Power Platform: Use AI to evaluate every incoming email

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.

Power Automate: Set email category

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.
  • Add the Send an HTTP request action.
  • Set the URI to be following code.
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/triggerOutputs()?['body/id']
  • Set the method to PATCH
  • Use the following JSON code for the body
{
"categories": ["AI Finished"]
}
  • Set the Content-Type to application/json.
  • Save the flow.

Power Apps: Hidding and showing a component

I was tasked with developing a canvas app for a client that required each screen to include a popup element. The popup needs be openend by clicking an image, upon being clicked, it triggers a popup screen where users can compose a message. I utilized a Library Component and explored methods to control its visibility effectively. The challenge was ensuring that the message popup would appear when an image is clicked and disappear upon user interaction with a designated button. My solution involved manipulating the component’s dimensions — adjusting the height and width to expose only the image or to reveal the entire component. This technique successfully creates the perception of the popup screen being opened and closed by the user.

  • The first step is to create a solution with a canvas app and a component library.
  • In my example I named the component comp VIM Message.
  • Then open the component.
  • Set the size of the component to 640 by 640.
  • Add two custom output properties to the component named CompVIMHeigt and CompVIMWidth.
  • Set the component width to ‘comp VIM Message’.CompVIMWidth
  • Set the component height to ‘comp VIM Message’.CompVIMHeight
  • Set the component reset to Set(varCompHeight, 80);
  • Add an image element and set the following code on the Onselect. This will make the container visible and make the component bigger.
Set(varComVIMVisible, true);
Set(varCompHeight, 640);
Set(varCompWidth, 640);
  • You might need to adjust the numbers based on your needs.
  • Also set the X and Y properties on your image based on your needs. I use the following.
X = 'comp VIM Message'.Width - 55
Y = 15
  • Add a container with the element you need in the popup.
  • Set the following properties of the container.
Visible = varComVIMVisible
Height = 440
Width = 520
X = 75
Y = 190
Visible = varComVisible
  • Add two buttons in the container one called Cancel (in Dutch that would be Annuleren) and Send (in Dutch that would be Verzenden).
  • Set for both button the onselect to the following code, this will make the component smaller and hide the container.
Set(varCompHeight, 80);
Set(varCompWidth, 60);
Set(varComVIMVisible, false);
  • Open the canvas app and add the component comp CIM Message.
  • Insert the component into the canvas app.
  • Set the Heigth property to the following code. This will make sure the Height has a value when the canvas app page is loaded.
If(IsBlank('comp VIM Message_HS'.CompVIMHeight), 80, 'comp VIM Message_HS'.CompVIMHeight)
  • Set the Width property to the following code. This will make sure the Width has a value when the canvas app page is loaded.
If(IsBlank('comp VIM Message_HS'.CompVIMWidth), 60, 'comp VIM Message_HS'.CompVIMWidth)
  • Set the X property to the following code. This will make sure that the Image part of the component is on the left top side of the screen.
If('comp VIM Message_HS'.CompVIMWidth = 640, 'Home Screen'.Width - 640, 'Home Screen'.Width - 60)
  • Now run the canvas app and see if it works (it might not work in the play function in the edit mode).