ADX Portal – Display ‘Message’ during maintenance window

February 14, 2020 Leave a comment

There might be times when your Portal is under scheduled maintenance or is down due to temporary outage. When a user accesses the portal during maintenance, unpredictable behavior and intermittent unavailability might be experienced.

In ADX portal we can display a message to users during a maintenance activity by following below steps:

  • Create a HTML page with the message you would want to display.
  • Save it as ‘App_Offline.htm‘.
    • Make sure the name of the file is exactly same.
  • Place this file in root folder of ADX website.

Portal_Maintainence_1

  • ADX always opens ‘App_Offline.htm’ page, if it finds in root folder.
  • Hit the portal URL and you would get the ‘App_Offline.htm’ page, which displays your maintenance message.

Portal_Maintainence_2

🙂

 

Categories: ADX Tags: ,

PowerApps Portal – Enable Maintenance mode

February 13, 2020 Leave a comment

During a scheduled maintenance or due to a temporary outage, If you want to bring down your portal and display a proper message to users, PowerApps portal has “Enable Maintenance mode” option.

In this article lets see how to use ‘Enable Maintenance mode’ option.

Prerequisites:

  • Subscribe to 30 days trial and procure an Office 365 account.

Steps to navigate to Portals admin center:

  • Connect to Power Apps maker portal using Office 365 account.
  • Create a new PowerApps portal app, if you don’t have already.

PPortal_Maintainence_6

  • Now from the ‘Apps’ tab, select your portal and go to ‘Settings’.

PPortal_Maintainence_2

  • From the ‘Portal settings’ pane, click on ‘Administration’ link.

PPortal_Maintainence_1

  • You will be redirected to ‘PowerApps Portals admin center’.

PPortal_Maintainence_3

Enable/disable Maintenance mode:

  • Select ‘Portal Actions’ tab and click on ‘Enable maintenance mode’

PPortal_Maintainence_4

  • You get the ‘Enable maintenance mode’ popup.

PPortal_Maintainence_5

  • Under Select page to be used when maintenance mode is enabled: Select one of the following values:
    • Default page: Select this value if you want the default page to be displayed. By default, this option is selected.
    • Custom page: Select this value if you want a custom HTML page to be displayed.
      • Custom page URL: You must ensure that the page URL you provide is publicly accessible. 
  • I opted ‘Default page’ option and clicked on ‘Enable’.
  • If you browse the portal, you would get following screen:

PPortal_Maintainence_7

Notes:

  • When the maintenance mode is enabled, the customers are restricted from browsing any webpages except the <portal URL>/_services/about page.
  • If you opt for ‘Custom page’ option, make sure, the custom page you provided should not contain the x-frame-options:SAMEORIGIN response header, else the page will not load.

🙂

 

Power Platform – Pass external API collection from Power Automate to Canvas App

February 9, 2020 1 comment

In this article, lets see how to pass an external API’s json collection from Power Automate(Formerly ‘Microsoft Flow’) to a Canvas application.

For this example, I am going to use ESRI  mapping service API, in my Power Automate Flow. Refer here to know more about ESRI. You may also use other APIs as per your convenience.

ESRI API is url based and returns the ‘Address Suggestions’ in json format.

Flow_Json_3

Before we start lets make sure to meet all the prerequisites.

Prerequisites:

  • Subscribe to 30 days trial and get Office 365 account.
  • Connect to Power Automate portal using Office 365 account to build Power Automate flow.
  • Connect to Power Apps maker portal using Office 365 account to build the Canvas App.
  • ESRI api URL – Refer my previous article on the usage of ESRI or you can simply use this url

Once all prerequisites are met, here is the high level design:

  • Create a new Power Automate flow and call ESRI API to fetch Address Suggestions.
    • You can take any open API which returns json collection.
  • Parse the ESRI API Response to json collection.
  • Create a new Canvas app
  • Trigger Power automate flow from Canvas App and read the collection.

Lets get started.

Steps to configure the Power Automate Flow:

  • Connect to Power Automate portal
  • Create a new ‘Instant flow’ by selecting the right Environment.

Flow_Json_1

  • Provide a name ‘GetAddressSuggestions’ and select trigger as ‘PowerApps’

Flow_Json_2

  • To call ESRI api, add a new ‘HTTP’ action.

Flow_Json_4

  • Choose Method as ‘GET’ and in URI paste the ESRI url as mentioned in prerequisite section.

Flow_Json_5

  • Next, we need to parse the response from ESRI api. As the ESRI results would be in json format, add ‘Parse JSON’ action.

Flow_Json_6

  • In ‘Parse JSON’ action,
    • set Content as ‘Body’ from HTTP action.
    • Next we need to provide the json schema of ESRI response. To do that, click on ‘Generate from sample’.
    • Flow_Json_9
    • Now copy the response from ESRI API (Copy the browser’s output using ctrl+a+copy)
    • Flow_Json_7
    • Paste in the ‘Insert a sample JSON Payload’ window and click ‘Done’.
    • Flow_Json_8
    • If no warnings, your ‘Parse JSON’ pane should look as below.
    • Flow_Json_10
  • As we completed the ESRI response capture and parsing to json, now we need to pass the captured json response to Power App.
  • To pass the json response to Power App, add a new ‘Response’ action.

Flow_Json_11

  • In the ‘Response’ pane,
    • Set the ‘Body’ to ‘Body’ from ‘Parse JSON’.
    • Flow_Json_12
    • Expand ‘Show advanced options’ and click on ‘Generate from sample’.
    • Copy the response from ESRI API and paste in the ‘Insert a sample JSON Payload’ window and click ‘Done’. (Same step like we did in ‘Parse JSON’ pane).
    • ‘Response’ pane should look as below with no warnings.
    • Flow_Json_13
  • Run the flow and make sure it ran successfully.

Flow_Json_18

Steps to configure the Canvas App:

As we completed the Power Auto Flow, now its time to consume the Power Automate flow response from Canvas App by following the steps below

  • Connect to Power Apps maker portal using the same Office 365 account.
  • Create a new Canvas App.
    • Note: Make sure the same Environment used for Power Automate is selected.
  • Add a new button.
  • Select the button, from the ribbon menu, click on ‘Action -> Power Automate’.
  • From the pane select the ‘GetAddressSuggestions’ Power app flow.

Flow_Json_14

  • After few seconds, you would see the Run() command auto populated as below.

Flow_Json_15

  • As we going to get json collection from flow, lets capture the json collection to a collection variable ‘collAddress’ using ‘ClearCollect()’. Refer article to know more about ‘ClearCollect()’.
  • With the ClearCollect() and Run() functions, the final ‘OnSelect’ statement should look as below.

Flow_Json_16

  • Lets run the App and click on the button. Application takes couple of minutes to complete the run.

Flow_Json_17

  • Post run, check the collection returned from flow by going to ‘File -> Collections’ tab.

Flow_Json_19

  • You can also add a ‘Data table’ control and display the results returned from flow as below

Flow_Json_20

🙂

 

Power Platform – Pass json collection from Canvas App to Power Automate

February 9, 2020 1 comment

Refer my previous article for steps to pass json collection from Power Automate to Canvas App.

Now lets see how to pass json collection from a Canvas app to Power Automate flow.

Before we start lets make sure to meet all the prerequisites.

Prerequisites:

  • Subscribe to 30 days trial and get Office 365 account.
  • Connect to Power Automate portal using Office 365 account to build Power Automate flow.
  • Connect to Power Apps maker portal using Office 365 account to build the Canvas App.

Once all prerequisites are met, here is the high level design:

  • Create a new Canvas app.
  • Prepare a json collection.
  • Create a new Power Automate flow.
  • Trigger Power automate flow from Canvas App by passing the collection as parameter.
  • Read the json collection from Power Automate flow.
  • Create ‘Contact’ records in CDS.

Lets get started.

Steps to configure Canvas App:

  • Connect to Power Apps maker portal using the Office 365 account.
  • Create a new Canvas App.
    • Note: Make sure the same Environment used for Power Automate is selected.
  • Add a new button ‘Generate Sample Collection’.
  • On button’s ‘OnSelect’ prepare a json collection using ‘ClearCollect’ function as below.

Flow_Json_21

  • Once your run the App and click ‘Generate Sample Collection’ button, you should see the collection from ‘File -> Collections’ tab.

Flow_Json_22

Steps to configure the Power Automate Flow:

  • Connect to Power Automate portal using the same office 365 credentials used to connect to Power App portal.
  • Create a new ‘Instant flow’ by selecting the right Environment.

Flow_Json_1

  • Provide a name ‘GetCollectionFromPowerApp’ and select trigger as ‘PowerApps’.
  • Now, we need to read the collection passed from Canvas app to a variable. Lets add a new ‘Initialize Variable’ action.
  • In the ‘Initialize Variable’ action,
    • Provide variable name by setting ‘Name’ field. I set it as ‘collPersons’.
    • Type: String
    • Select ‘Value’ and click on ‘Ask in PowerApps’. A auto generated name would appear and select the same.
    • Flow_Json_25
  • Once we receive the collection and stored in a string variable ‘collPersons’, next we need to parse in to json collection.
  • Add a new ‘Parse JSON’ action.
  • In ‘Parse JSON’ action,
    • set Content as ‘collPersons’ from ‘Initialize Variable’ action.
    • Next we need to provide the json schema coming from Canvas app. To do that, click on ‘Generate from sample’.
    • Copy the json collection formed in Canvas app using ClearCollect function and paste as below.
    • Flow_Json_27
    • If no warnings, your ‘Parse JSON’ pane should look as below.
    • Flow_Json_28
  • Now we got json collection parsed and we are good start final step, creating records to CDS.
  • Add ‘Create a new record’ CDS action and select the ‘Environment’ and ‘Entity Name’

Flow_Json_33

  • Set the attributes (Last Name and Email) from ‘Parse JSON’ action.

Flow_Json_34

  • Once you set variables in ‘Create a new record’ CDS action, flow would automatically wrap the action in ‘Apply to each’.

Flow_Json_29

Trigger the Power automate flow from Canvas App:

Now we have Power automate flow with the logic to read and parse the json collection and add them to CDS as Contact records, lets trigger the flow from Canvas App.

  • Open the Canvas app created in above sections.
  • Add a new button ‘Share Collection To Flow’
  • Select the button, from the ribbon menu, click on ‘Action -> Power Automate’.
  • From the pane select the ‘GetCollectionFromPowerApp’ Power app flow.
  • After few seconds, you would see the Run() command auto populated. Now pass the ‘collPersonalInfo’ collection wrapped in JSON() function.
    • JSON() function is required to convert the ‘collPersonalInfo’ collection to JSON string as the Power Automate flow expects ‘String’ variable as first action.
  • Finally ‘OnSelect’ should look as below.

 

Flow_Json_30

  • Now run the App and click ‘Share Collection To Flow’ button, post run, go to Power automate flow’s history and you should see it ran successfully.

Flow_Json_31

🙂

Categories: CRM, PowerApps Tags: ,

‘Failed during http send request’ error – Triggering Power automate from Canvas App

February 9, 2020 Leave a comment

While configuring Canvas app for my previous article ,I encountered following error while selecting ‘Power Automate’ from Canvas app.

Flow_Json_23

Reason:

  • In my ‘Power Automate’, I was reading collection received from Canvas app to ‘Array’ type variable.

Flow_Json_24

  • There seems to be issue with ‘Array’ datatype when triggering ‘Power Automate’ flow Canvas App.

Fix:

  • In the Power Automate, changed the Type from ‘Array’ to ‘String’ and used ‘Parse JSON’ action to convert String to json collection.

Flow_Json_25

  • In Canvas App, used JSON() function to convert the Collection to json string.

Flow_Json_30

🙂

Power platform 2020 release wave 1 – Plan and features list

February 7, 2020 Leave a comment

The Power Platform release plan (formerly release notes) for the 2020 release wave 1 has been published with great new features.

Refer here for the details and download from here for the full list of features.

Following are the standout features for me:

  • Canvas apps:
    • Monitor tool – Allow makers to diagnose and troubleshoot their applications quicker
    • Create an app from data in a landscape format instead of just a phone layout.
  • Model Driven Apps:
    • Edit/Create related records without navigating away – Users do not have to navigate away from a form to create or edit a related record

PAPP_Wave2020_2

  • Power app Portal:
    • Web APIs for CRUD operations on Common Data Service entitiesThis is much awaited feature as former portal versions would only allow Read outside of ‘Entity Forms’ using Liquid script.
    • Power BI Embedded component in portal designerPortal provides the first party integration with Power BI by using the liquid tags
    • Simplified themes in portals Studio
    • Support for additional entities in global searchNow you can enable Global Search on Custom entities as well using a ‘Site Setting’ configuration.

PAPP_Wave2020_1

  • Power Automate:
    • Solutioning support for UI flowsWith this feature, you can create your UI flows in solutions, easily export them into a package, and then import them across different environments for your ALM needs.
    • Azure integration with Power AutomateOption to create flows by using a template from the Azure portal
    • Copy and paste in Power AutomateIf you want to duplicate actions in the Power Automate designer, you can now copy and paste them.
    • UI FlowsWith UI flows in Power Automate, you can record mouse clicks, keyboard use, and data entry to automate manual, repetitive, and time-consuming tasks to improve workplace productivity
  • Power Virtual Agent:
    • Add a Power Virtual Agents bot into Power Apps canvas app.
    • Add images and videos to topics.

🙂

 

Power Apps – Custom help panes and guided tasks

February 2, 2020 Leave a comment

Custom help panes and guided tasks gives your Unified Interface application a custom in-product help experience that is tailored to your organization.

Custom help panes replace the previous learning path guided learning feature used with legacy web client apps.

How to enable Custom help panes and guided tasks:

  • Open your Power App
  • Using ‘Advanced Settings’, Go to Settings -> Administration

GuideTasks_8

  • Choose “Custom help panes and guided tasks” to ‘Yes’

GuideTasks_1

Configuring Help pane content:

In my example, I am using ‘Fund Raisers’ Model driven app. To configure ‘Help pane content’ for ‘Fundraiser’ entity:

  • Select the ‘Fundraisers’ from the Sitemap.
  • Click on ‘?‘ and from the ‘Help Pane’, select ‘Edit’ option as shown below.

GuideTasks_2

  • Using the Rich text editor, you can configure the rich content.
  • Use ‘Balloon’ option to point to specific UI elements with text.

GuideTasks_4

  • To add ‘Balloon’ on ‘Delete’ button, use ‘Drag to an element‘ option and point to the ‘Delete’ button.

GuideTasks_3

  • Once configured, Balloon would show up as below

GuideTasks_5

  • You can also add Images, Links and Videos.

Moving Help content via Solutions:

  •  If you want to move your content to another environment, first add your existing help pages into an unmanaged solution before you export them.
  • From the ‘Add Exisitng’ components, select ‘Help Page’.

GuideTasks_6

  • Select the available ‘Help content’ records and add to the Solution.

GuideTasks_7

Who can author help pane content:

  • By default, System Administrator and System Customizer security roles both have this privilege.
  • For other security roles, grant Global create, read, write, delete, append, and append to permissions on the Help Page privilege.

Notes:

  • To author custom help panes, you need to be on version 9.1.0.10300 or later.
  • You can enable custom help panes or customizable help, but not both at the same time.
  • Each help pane is unique for these contexts: Application, Entity, Form, Language

Refer here for more details.

🙂

Power Apps Portal – Multi Language – ‘Invalid website language’ error

February 1, 2020 Leave a comment

Other day, while configuring multi language on Power Apps portal, I was getting following error while adding ‘Hindi’ as new ‘Website Language’.

Portal_Lng2

Reason:

  • ‘Hindi’ language was disabled by default in CDS.Portal_Lng5

Fix:

  • From your portal’s ‘Model Driven’ App, go to ‘Advance Settings’, which opens up classic ‘Settings’ sitemap area.

Portal_Lng4

  • Under ‘Settings -> Administration -> Languages‘ select the Language which you want to enable and click ‘Apply’.

Portal_Lng6

  • Now go to the portal’s ‘Model Driven’ App and you should be able to create new ‘Website Language’ with enabled ‘Language’ (i.e., Hindi).

Portal_Lng7

How Multiple Language works in ‘Power Apps Portal’:

  • To enable a new localization (i.e., Language), add a new ‘Localized Content’ record, to every Portal ‘Web Page’.

Portal_Lng8

  • ‘Localized Content’ record will have a ‘Portal Language’ lookup of ‘Website Language’ record.
  • To add ‘Hindi’ localization to the ‘Web Page’ add a new ‘Localization Content’ record with ‘Portal Language’ lookup set to ‘Hindi’ website language (Refer ‘Fix’ section for how part).

Portal_Lng9

  • Make sure ‘Published State’ of ‘Localized Content’ is ‘Published’.

Key Notes:

  • By default a ‘Localization Content’ record pointing to base language (i.e., English in my case) gets created when you create a new ‘Web Page’.
  • Web Link Sets:
    • When a new language is activated , a new set of links are created for the newly activated language.

Portal_Lng11

  • Content Snippets:
    • When a new language is activated , a new set of Snippets are created for the newly activated language.
    • Refer link on usage of ‘Content Snippets’

Portal_Lng10

  • If you activate a new language after enabling Portal, the metadata will not be installed automatically for the newly activated language.
  • To get the metadata translation for the newly activated language, you must import the metadata translation from the Power Apps Portals admin center.

🙂

 

ADX Portal – Prevent URL redirection

January 28, 2020 Leave a comment

Recently our ADX portal underwent Penetration testing (Also called ‘Ethical hacking’) and we got a following recommendation:

Prevent on-domain URL redirection. All URL redirection should be validated to only redirect to approved domains and/or URLs.

Reason:

  • In ADX portal, when ever you signed out or the session expires from a particular ‘web page’, Portal will take you back to the ‘web page’ you were before you signed out.
  • ADX portal achieves this behavior by appending ‘ReturnURL‘ parameter to the URL. ‘ReturnURL’ contains the web page path before you signed out.

ADX_Redirect_2

Whats the harm with this behavior?

  • ADX portal, will try to redirect to the URL formed in ‘ReturnURL’.
  • An attacker can redirect users from portal to a specific URL (Phishing).
    • As an example, attacker can mail you a link with Portal URL along with ‘ReturnURL?myphishingsite.com‘.
    • If the user think, its a genuine Portal URL and sign-in, ADX portal would redirect you the myphishingsite.com as the same was mentioned in ‘ReturnURL‘.

How to handle this in ADX website?

  • We modified the ‘Login’ logic to ignore ‘ReturnURL’ and redirect Users to portal’s Home page always.
  • All we need to do is
    • Set returnUrl=”/” on ‘LoginController.cs -> Login’ function.

ADX_Redirect_1

  • We can also modify the logic to allow redirection only to a set of URLs.

🙂

 

Categories: ADX Tags: , ,

Power Apps – Understanding ‘Variables’

January 26, 2020 1 comment

If you are a ‘Power Apps’ beginner and wonder how to declare and use variables like the way you do in any of your favorite programming language (C#, Java, PHP, etc..) this article is for you.

Before we jump in to ‘Power Apps’ Variables, lets first understand following things:

  • ‘Power Apps’ is different and works more like Excel.
  • Power Apps and Excel both automatically recalculate formulas as the input data changes, without the need of Variables.
  • In below screen,
    • Sum of A and B is being calculated and set to the Label just by summing up the Text values directly like a formula.
    • If either A or B value changes, Label will recalculate the value.

PA_Var1

Why we need variables in ‘Power Apps’?

  • In general, its recommended to avoid using variables in Power Apps.
  • But sometimes only a variable can enable the experience you want.
  • To understand this, lets tweak the previous screen by adding a Button and Sum up the values on button click.

PA_Var2

  • Here we can’t use formulas (i.e., Like screen 1) to calculate the Sum because its value depends on button Click.
  • We require a variable to hold the Sum before its set to the Variable to display.

Types of Variables:

Power Apps has three types of variables:

PA_Var3

Global Variable:

  • You set the value of the global variable with the Set function.
    • Set( Var_Name, 0 ) sets the global variable to a value of 0.
  • Global variables can hold any value, including strings, numbers, records, and tables
  • In my example, on ‘OnSelect’ of ‘Calculate’ button, using ‘Set’ function, I am setting Sum of txt1.Text and txt2.Text to a Global variable ‘globalVar‘.

PA_Var5

  • And setting the ‘Text’ of ‘Label’ to Global variable ‘globalVar‘.

PA_Var6

  •  Global variable scope is ‘App’ level, can be references from anywhere in the app. Which means, I can read the ‘globalVar‘ from a different screen (i.e., Screen2).

PA_Var7

Context Variable:

You implicitly establish and set context variables by using the UpdateContext or Navigate function.

UpdateContext:

  • UpdateContext( { Var_Name: 0} ) sets the context variable to a value of 0.
  • Context variables can hold any value, including strings, numbers, records, and tables
  • In my example, on ‘OnSelect’ of ‘Calculate’ button, using ‘UpdateContext’ function, I am setting Sum of txt1.Text and txt2.Text to Context variable ‘ctxVar‘.

PA_Var8

  • And setting the ‘Text’ of ‘Label’ to Context variable ‘ctxVar‘.

PA_Var9

  • ‘OnSelect’ of ‘Clear Context Variable’ button, I am setting ‘ctxVar‘ to 0.

PA_Var10

  • Context variable set using ‘UpdateContext’ function’s scope is ‘Screen’ level, can only be references with in the screen.

Navigate:

  • You can also set a context variable when you use the Navigate function to show a screen.
  • In the example below, lets add a new button ‘Navigate to Screen2’ and on ‘OnSelect’, navigate to ‘Screen2’ by passing ‘ctxvar‘ as argument.
    • Navigate(Screen2,ScreenTransition.Fade,{ctxvar:txt1.Text+txt2.Text})

PA_Var11

  • On ‘Screen2’ set the Label’s text to ‘ctxvar’.

PA_Var12

  • Run the application, click on ‘Navigate to Screen2’

PA_Var13

  • On the ‘Screen2’ we get ‘ctxvar’ value displayed in label.

PA_Var14

  • Important thing to notice is, Except for Navigate, context variables are limited to the context of a single screen, which is where they get their name. You can’t use or set them outside of this context.

Use Collection:

  • Collection holds a table that is easy to modify.
  • Create and set collections by using the ClearCollect function.
    • You can use the Collect function instead, but it will effectively require another variable instead of replacing the old one.
  • In my example, on ‘OnSelect’ of ‘Add to Collection’ button, collect the ‘txt1.Text’ values to a collection ‘collSum‘ using Collect(collSum,txt1.Text)

PA_Var15

  • We clear the Collection ‘collSum‘ using Clear(collSum) function.

PA_Var16

  • To display the ‘collSum’ values, add a ‘DataTable’ control and set ‘Data source’ to ‘collSum’.

PA_Var17

  • Run the application and keep adding the values. You should see collection values in a table as below.

PA_Var18

Notes:

  • You can see the Variables and Collection on the File menu of your App.

PA_Var19

  • If you give a context variable the same name as a global variable or a collection, the context variable takes precedence. However, you can still reference the global variable or collection if you use the disambiguation operator @[Var_Name].
  • All variables are held in memory while the app runs. After the app closes, the values that the variables held are lost.
  • When the user opens the app, all variables have an initial value of blank.

🙂