Logged In User details in a Canvas Power App

You do get some details of the logged in user in a Canvas Power App. Let’s look at what all is available –

undefined

User() Function

User() function provides 3 pieces of information you can retrieve at this point in terms of logged in user.

undefined

Email

Use User().Email to populate a Text field with the Email address of the logged in user.
undefined

Full Name

Use User().FullName to fetch the logged in user’s Full Name and maybe, populate it in a Text/Label field as well
undefined

Image

Use User().Image to be able to populate the Picture control with the logged in User’s Picture. Remember, user needs to add this in their respective Office 365 account in order to appear here
undefined
undefined

User Details

Now, whenever a logged in user comes across these controls which we set above, the User details will vary for each user respectively. Below is how it looks for me.

undefined

You can obviously use it as and where it suits you.

Here are some more Canvas Power Apps posts you might want to look at –

  1. Variables in Canvas Power Apps | Global and Context
  2. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  3. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  4. Adding a Canvas PowerApp to Teams
  5. Sending Image from Canvas PowerApps to SharePoint Document Library using Flows

Hope this was easy and helpful!

Advertisement

Loop through array of objects in a Flow & Create records in CDS | Power Automate

One of the most common scenarios that are looked out for are ways to loop through an array of objects received (say, from HTTP response) and create CDS records

Sample Data

Let’s say this is the sample data coming in which is an array of objects. This is coming from my HTTP trigger which I created and hosted. It could be anything else in your case
undefined

And the body looks something like this –

[{"Name":"FreshBeans Coffee","City":"Mumbai","Phone":999999999},{"Name":"Timber Mart","City":"Pune","Phone":999999999}]

Generate Schema from Payload

I need to first create the Schema to be able to easily read from the JSON response
undefined

Paste a sample Payload in the dialog box
undefined

And it will generate a Schema
undefined

And when this is generated, you can access the attributes further in your Flow
undefined

What if you just enter a blank object and not generate from Schema or enter Schema explicitly as shown below –
undefined
You won’t get the attributes from the JSON Payload which is needed further
undefined

Loop through array and Create in CDS

Now, you can use Apply To Each and pass the Parsed JSON Body. I’ve simply used Compose to see the entire Object while checking results (No other purpose of using Compose in this example)
undefined

And then the next step is to Create CDS records from the looped Objects. So, since I have the schema generated above, I can use the attributes to directly map it to the CDS Create Record action

undefined

Running the Flow

Finally, once I run the Flow and check the actions performed. I’ll create 2 records since there are 2 objects in my array.

I’ll see the Compose step to see what I got in the object. As I mentioned earlier, this is not required- I just intend to put it there to see what data came in
undefined

And the Create Record in CDS step will create record in my Dynamics 365 environment as I intended it to do –
undefined

I can check the same in Dynamics 365
undefined

You might also want to check other posts related to Power Automate –

  1. Get Count of records retrieved in CDS connector in a Flow | Power Automate
  2. Number Formatting in a Flow | Power Automate
  3. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  4. Switch-Case in a Flow | Power Automate
  5. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  6. Make HTTP request from Flow in Power Automate
  7. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  8. Enable Flow button on D365 Ribbon

Hope this was easy!

Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App

Most common scenarios are where you need users to be able to Exit the Canvas Power Apps in the below ways –
Scenario – Let’s say you put a close button somewhere in your App.
undefined

  1. Exit the current App but stay logged-in to Power Apps.
  2. Exist and Logout Power Apps entirely.
  3. In both above cases, ask user for confirmation before exiting.

So let’ look at these scenarios one by one –

Exit from current App

  1. Now, let’s say you’ve put a Close button on your App like this. And when you click it –
    undefined
  2. It takes you to the App selection screen in your Power Apps
    undefined
  3. You can implement this using Exit() method on OnSelect property of the Close button as shown below
    undefined

    And that’s it.


Exit and Logout of Power Apps

  1. Another variation to the same feature would be to Exit the App as well as Logging out completely. Now, I’ve put a Lock button here to represent Logout.
    undefined

  2. You can implement this by using Exit(true) method as shown below
    undefined
  3. And, it will logout the PowerApps Application itself.
    undefined
    And you’ll need to log in all over again.

Confirm before Exit

This is a feature that will work with both, Exit() and Exit(true). It will ask you for a confirmation on whether if you really like to close/logout the app?

  1. Select App in the left-hand Tree view, select App
    undefined
  2. And look at the right hand Properties menu – The Confirm exit and Confirm exit message will let you enable this feature with the message you want to display –
    undefined

    And you can set your message
    undefined
  3. And then, when you either Logout or try to Close the App, you’ll be prompted with this message
    undefined


    Note: For all the changes to take place in Canvas Power App, make sure all changes are Published and you force close and re-open the Power App (if using on a mobile device / Tablet). Wait for a few seconds to get notified about the latest version being available.

And it’s all that simple! In case you are looking for more articles on Canvas Power Apps, you might want to check these below –

  1. Variables in Canvas Power Apps | Global and Context
  2. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  3. Adding a Canvas PowerApp to Teams
  4. Correctly connect to an Excel file in a Canvas PowerApp
  5. Sending Image from Canvas PowerApps to SharePoint Document Library using Flows

Hope this helps!

Get Count of records retrieved in CDS connector in a Flow | Power Automate

In several applications, you need to know how many record were retrieved in the List records Action in a Common Data Service connector in order to take a decision.

Scenario

Typically, let’s say I know only 1 record should exist in order to take that record forward and do an action. But how do I know when only 1 record was received? That’s when you use Control

Check Count

Now, let’s say you want to want to retrieve Accounts and know how many were returned (Perhaps, you want to proceed only if at least 1 or more were retrieved)

  1. This is my List Records action and I’ve named it as Get All Records.
    defaultListRecords
  2. And just to display how many records are retrieved, I’ll use a variable. Usually, you would use this in condition (which we’ll get to in a bit)
    initVar
  3. So, in the expressions to set the Variable, under Dynamic Content, I’ll write –
    writeHereand write the below expressioncountactualExpression
    which is set to the variable
    setVar
  4. And here are the results. I have 101 Accounts
    count

Using it for comparison

This is one of the typical use cases where you want to proceed only if you have at least 1 record –
typicalUseCase

Here are some more Flow related topics you might want to take a look at –

  1. Number Formatting in a Flow | Power Automate
  2. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  3. Switch-Case in a Flow | Power Automate
  4. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  5. Retrieve only active Dynamics 365 CE licensed Users in CDS connector in Power Automate
  6. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  7. Make HTTP request from Flow in Power Automate
  8. Create a To-Do List Item of Important Outlook Emails using Power Automate

Hope this quick tip helps!

Variables in Canvas Power Apps | Global and Context

For all newbies, being able to use Variables is one the most curious questions put out immediately. Here’s a simplistic example of using Variables, both Global and Contextual in this post.

headerImg

Global Variable

Global Variables as the name suggest, run through the entire App itself and can be changed and altered when needed.
Global variables can hold boolean, string, number etc.

  1. Let’s say, I have a Text field called GuestNameField
    guestFieldAdded
    guestNameFieldView
  2. Global Variables are created and set by using Set(variable, value) function.Now, on the OnChange event of the GuestNameField above, I’m setting the variable by the formula Set(guestName, GuestNameField.Text). Where, guestName is the field I created on the fly and I’m setting the text from the GuestNameField textbox whenever the Textbox will trigger OnChange Event.
    formulaWritten
  3. And I have a Label called as DisplayValue which will read from the variable and set it’s text.
    readFromVar
  4. Now, when I run the app and type the name, and when I release the focus on the text box, the
    typeName
    And when the focus from the TextBox is released, OnChange of the TextBox will trigger and the Label will display the text written since it’s reading the value from the variable
    appear

Context Variable

Now, a variation to the Context Variable from the Global Variable is that the Context variable have the scope of the only the current screen they are declared in. Navigate function is also a form of Context variable in which case, you can pass values to other screens.

Context variables can hold strings, numbers, records and tables.

  1. Now, in case of Context Variables, you use UpdateContext({variable: value}) in the formula.
    contextVar
  2. And is accessed/read by simply writing the name of the variable directly
    directContextVarName
  3. And it behaves in the same way, you write something and it can be read
    typeName
    And displayed below as seen in the above Global Variable example
    appear

Checking your Variables

In case you’re wondering you’ll lose track of your variables, you can check the File menu and access the Variables section as shown below
menuItem

Global Variables as marked above can be accessed in their own section
globalStored
And if you open any of those, you can see and even navigate to where they are used.
globalUsage

Similarly, for Context Variables are denoted by the Screen names they are in.
contextStored

I tried to summarize this on a high level. You can refer this Microsoft Documentation for details Understand canvas-app variables in Power Apps.

Hope this was easy!

In case you are looking for more post related to Canvas PowerApps, here you go –

  1. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  2. Adding a Canvas PowerApp to Teams
  3. Correctly connect to an Excel file in a Canvas PowerApp
  4. Sending Image from Canvas PowerApps to SharePoint Document Library using Flows

Thank you!

Number Formatting in a Flow | Power Automate

Quite obviously this is one of the most common asks in Flow to format a number. Here are some ways to do so using Format number Action in Flow (Power Automate).

This is available in Format number action in a Flow in Power Automate. This is available in Number Functions connector.
numActions

Commas and Decimals

  1. For a standard simple number, you can simply denote by # and commas or other symbols where needed. Here, I won’t select any locale.
    standardNumberBody
  2. And it would render into this –
    standardNumber

Phone Number

  1. US phone is an example where it is denoted by brackets and dashes in between. I’ll select English (United States) (en-US) in the locale among others. So, my format would be.
    isPhoneBody
  2. And the resultant phone number will be set as below
    usPhone

Currency Input

For currency, this is what I did –

  1. Added ₹ followed by ##,###,###. I’ll select English (India) (en-IN) in the Locale field.
    indCurrencyBody
  2. So even though my number value i.e. (50000) is in thousands and not hundred-thousands as I covered in my format, it’ll consider the correct format used and my output will be – indCurrency

Here’s where you can look at other ways to format numbers –
1. Standard numeric format strings
2. Custom numeric format strings

If you’re looking for some more posts on Flow / Power Automate, I’ve written some in the past. Check these –

  1. Create a To-Do List Item of Important Outlook Emails using Power Automate
  2. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  3. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  4. Switch-Case in a Flow | Power Automate
  5. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  6. Make HTTP request from Flow in Power Automate
  7. Using Parse JSON to read individual List Records in Flow|Power Automate
  8. Secure Input/Output in Power Automate Run History
  9. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  10. Enable Flow button on D365 Ribbon

Hope this helps!

Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform

One of the most common asks when using CDS as Data Source in a Canvas Power Apps is – How do I get the data from N:N entities?

Well, I’m attempting to explain this in the easiest way possible.

Scenario

Let’s assume Account entity has an N:N relationship with Account Plans entity

Account <–N:N–> Account Plans.

And in Dynamics 365, you simply add these records by going into related records and adding them using Add Existing button
addExistingInD365

And now, you want to access this data for a record in a Canvas Power App? Correct? Let’s get going with it.

Enable the Entities involved

In this example, the entities involved are Account and Account Plans

  1. Accessing data for N:N entities require the entities to be enabled for Change Tracking. Let’s check that in CDS
    settingsOfAccount
    changeTrackingEnabled
  2. And also the same thing for Account Plan entity as well
    settingsOfPlans
    changeTrackingEnabled

Reading Data in a Canvas Power App

I’ve kept the presentation of my Canvas Power App very crude, please excuse me for that.

Scenario: Now, let’s say you want to see the N:N data on selection of a record i.e. on selection of Account, you want to see what all Account Plans are added to that Account.

  1. Now, to demonstrate this, I’ve taken 2 galleries i.e. AccountGallery to show list of Accounts
    accountGallery
  2. And probably a list to just display what Account Plans are added (You can have any other control depending on what you want to do with these records). I’ll call the table AccountPlansTable
    accountPlansTable
  3. And my formula to display the N:N records will be –
    AccountGallery.Selected.’Account Plans’
    aboutToSelect
    finalFormula
  4. Now, you’ll need to add what fields should be shown from Account Plans entity to identify the records. Well, obviously, Name field is the most relevant here.
    I’ll click on Edit Fields for the AccountPlansTable
    editFields
  5. And add the name field from that entity
    nameAndAdd
  6. Once this is set, my App is ready to run
    preparedApp

Accessing the N:N records

Let’s run the app and see how we can read these N:N records
Once I click on ABC/1/2&3, I can see the related N:N records in the DataTable below
working
Simple enough!

Here are some more posts you might like –

  1. Create your first PowerApp! Connect to SharePoint Online List
  2. Dynamics 365 Solutions’ New Experience in Power Apps, Solution Checker and more
  3. AutoNumber field in CDS | PowerApps
  4. Sending Image from Canvas PowerApps to SharePoint Document Library using Flows

Hope this helps!!

Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate

Ever wondered how to call an Action from a Flow using the new Common Data Service (Current Environment) connector? There are 2 actions to perform this –

Here’s a quick post to demonstrate that and the difference between Perform a bound action and Perform an unbound action in the CDS (Current Environment) connector.

Note that the connector used here is Common Data Service (Current Environment) connector which is available only if you are creating a Flow inside a Solution, not outside.
currentEnv
Check more on this connector here – Selecting (Current) in Environment in Power Automate CDS connector and why it matters

 

Unbound Action

Bound Action meaning calling an Action in Dynamics 365 that is bound to any one entity i.e. which is not a Global Action
BoundAction

  1. In this example. I’m creating a Flow that will call a Bound Action which runs on Account entity.
    insideBoundAction_Body
  2. And the InputName field shown above will simply take a string field and reflect the same as it is in Output
  3. Now, I am using Perform a bound action Action from the Common Data Service (Current Environment) connector as shown below-
    selectBount
  4. Once you select Perform a bound action, you’ll need to select what entity the Action is tied to with the following properties –
    Entity Name: Name of the entity the Action is bound to
    Action Name: Name of the action (not Display Name)
    Item ID: Guid of the record of that entity. Typically this is dynamically retrieved from other operations above this step (I’ve simply hard-coded one)
    Parameters: In my example, I’m passing a parameter called ‘InputName’ and I’m passing a string called “Account Name”
    boundBody
  5. Operation-Now, once my Bound Action is executed, I can see the below results which it will return i.e. OutputName field after composing with InputName inside the Action
    boundOutput
  6. Further, you can use the following Output from the Bound Action i.e. the Response or the Output parameters the Action is sending.
    showBoundResponse

Unbound Action

Unbound Action meaning calling an Action that is not bound to any entity in Dynamics 365 and is set to None (Global)
CreateUnboundAction

 

  1. In my Unbound Action, I am simply passing InputName through to the OutputName field as is.
    insideUnboundAction_Body
  2. Now, I’ll use Perform an unbound action from the Actions in Common Data Service (Current Environment) connector
    selectUnbound
  3. Once you select this action, you simply need to select the name of the Action from Dynamics 365 itself (Again, not Display Name) and pass along any Input parameters for the same, if any.
    unboundBody
  4. Operation – Now, once you execute this, the Action will execute and give you a response as below
    unboundOutput
  5. Further, you can select what you want to use from the response of the action step i.e. either the Response itself or the Output Parameters, if any.
    showUnboundResponse

 

Here are some other Power Automate / Flow posts that might interest you –

  1. Switch-Case in a Flow | Power Automate
  2. Enable Flow button on D365 Ribbon
  3. Secure Input/Output in Power Automate Run History
  4. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  5. Using Parse JSON to read individual List Records in Flow|Power Automate
  6. Make HTTP request from Flow in Power Automate
  7. Retrieve only active Dynamics 365 CE licensed Users in CDS connector in Power Automate
  8. Create a To-Do List Item of Important Outlook Emails using Power Automate
  9. RSS notifications to your phone using Power Automate
  10. Selecting (Current) in Environment in Power Automate CDS connector and why it matters
  11. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  12. Approval Process using Power Automate

Hope this simple example helps explain the actions!

Modify Project tab’s view in Schedule Board in PSA v3 | Quick Tip

Most common asks on Schedule Board in D365 PSA is about how we can modify the Project tab view we see?

actualTabShown

Resource Requirement Entity

The Resource Requirement entity is what controls what views are available for you on the Schedule Board –

  1. To be able to find what this view is about, you’ll need to go to the Resource Requirement entity
    viewLocated
  2. Now, if I open this record, you can make changes to this view. In this case, I now got Type and Status next to Name field and pushed Created On a little further.
    modifiedPart
  3. Now, just Save and Publish.

Project Tab view

Now, simply refresh Schedule Board and you’ll see the updated change –
updated

If you’re looking for more PSA related posts, you can check these –

  1. Dynamics 365 PSA v2 to v3 Upgrade failed? Here’s what to do.
  2. Additional columns in PSA v3 Schedule view
  3. Update Price feature in D365 PSA v3
  4. A manager is required for non-project time entries, absence, and vacation error in D365 PSA v3
  5. PSA v3 View Custom Controls used on Project form
  6. Set Work Hours Template to a Bookable Resource in D365 PSA v3
  7. Time/Expense Entry Rejection comments in D365 PSA v3
  8. Booking Resources more than their capacity in D365 PSA v3

Hope this quick tip helps!!!