Power Fx | String Interpolation
If you are familiar with C# language’s string interpolation feature now Power Fx does too.
C# String Interpolation Example:
string name = "Mark";
var date = DateTime.Now;
// String interpolation:
Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");
In Power Fx, use string interpolation to embed formulas within a text string.
This is often easier to work with and visualize the output than using the Concatenate function or & operator.
Splicing a long string with the ‘&’ operator or ‘Concatenate’ function:
- Following is an example of splicing a string with ‘&’ operator or ‘Concatenate’ function.
"Hello User : " & User().FullName & " Your Email is : " & User().Email // '&' operator
Concatenate("Hello User : ",User().FullName," ;Your Email is : ",User().Email) // 'Concatenate' function
Using Power Fx String Interpolation:
Above String splicing can be easily done using String Interpolation
- Prefix the text string with a $ and enclose the formula to be embedded with curly braces { }.
- To include a curly brace in the text string, use repeated curly braces: {{ or }}.
- String interpolation can be used anywhere a standard text string can be used
$"Hello User : {User().FullName} Your Email is : {User().Email}"
Few more Examples:
$"2+3 = {2+3}"
// result: 2+3 = 5
$"{{this is inside curly braces}}" // result: {this is inside curly braces}
With( {x:5, y:7},
$"Point ({x},{y}) is {Text( Sqrt( x^2+y^2 ), "#.###" )} from the origin" )
// result: Point (5,7) is 8.602 from the origin
With( {FirstName: "John", MiddleName: "Q.", LastName: "Doe"},
$"{Trim( $"Welcome {FirstName} {MiddleName} {LastName}" )}, we're glad you are here!" )
// result: Welcome John Q. Doe, we're glad you are here!
🙂
[Step by Step] Model-driven apps | In-app notifications
Using in-app notification feature (Preview) we can notify Users with in the Model-driven apps. In this article lets learn how to enable the feature and use the in-app notifications with different options step by step.
Enable In-app notifications feature:
- Connect to Power Apps Maker Portal.
- Open the ‘Model Driven App’ using ‘Edit in preview’ option.
- In the App Editor, select ‘Settings -> Upcoming’ and enable the In-app notifications (Preview) as below.
Create a Test User:
- To test the In-app notifications, create a new user account. This User acts as recipient of notification.
- Note: If you already have more users in your environment, skip this step and use one of the existing Users as recipient.
- I’ve created an User named ‘Test User 1’ to send the notifications to.
- Open the Model driven app in another browser using the Test User account.
- Next copy the ‘Test User 1’ GUID by opening the User from ‘Advanced Find’. We will use this GUID while creating notification.
As we completed pre-requisites, its time to create notifications.
Creating our first notification:
- Notification features uses an OOB table called “appnotification”.
- We create a record in ‘appnotification’ table which turns out to be a notification for targeted User.
- Each notification row is meant for a single user, identified by the Owner column value.
- If a notification needs to be sent to multiple users, a record needs to be added for each recipient.
- The sender controls the recipient through the Owner column.
Following is code snippet is using ‘Client API’ to create a basic notification.
function showBasicNotification() {
// GUID of User (i.e.,Test User 1 in my case) whom you want to send the Notification to.
var systemuserid = "0758fd55-c2ca-ec11-a7b5-00224808dd66";
var notificationRecord =
{
"title": "Welcome",
"body": "Welcome to the world of app notifications!",
"ownerid@odata.bind": "/systemusers(" + systemuserid + ")",
"icontype": 100000000, // info
"toasttype": 200000000 // timed
}
// Create notification record
Xrm.WebApi.createRecord("appnotification", notificationRecord).
then(
function success(result) {
console.log("notification created with ID: " + result.id);
},
function (error) {
console.log(error.message);
}
);
}
- Register the showBasicNotification() function on one of the form jscript events (i.e., On Load/On Save/Field_OnChange).
- For this blog post, I’ve registered script on ‘On Load’ event.
- Use Browser ‘DevTools’ (F12) to check the successful execution of function.
- Up on executing the script, end user (i.e., Test User 1) would get a notification as below.
Notification with Action(s):
- Using “data” tag we can create notifications that include actions, custom body definitions, and custom icons.
- Following code snippet contain 2 actions (i.e., 2 URLs to navigate to) in Notification.
- ‘actions’ is an array.
function showNotificationWithMultipleActions() {
// Notification with multiple actions as center dialog
var systemuserid = "0758fd55-c2ca-ec11-a7b5-00224808dd66";
var notificationRecord =
{
"title": "Different Search Options",
"body": "This is to inform you that you can use following search options",
"ownerid@odata.bind": "/systemusers(" + systemuserid + ")",
"icontype": 100000000, // info
"data": JSON.stringify({
"actions": [
{
"title": "Bing",
"data": {
"url": "https://bing.com",
"navigationTarget": "dialog"
}
},
{
"title": "Google",
"data": {
"url": "https://google.com",
"navigationTarget": "dialog"
}
}
]
})
}
Xrm.WebApi.createRecord("appnotification", notificationRecord).
then(
function success(result) {
console.log("notification created with multiple actions: " + result.id);
},
function (error) {
console.log(error.message);
}
);
}
- Up on execution, End User gets a notification with 2 navigation actions as below.
Notification with a custom Title and Body:
- The data field supports overriding the Title and Body simple strings with a limited subset of markdown based.
- Below is the supported markdown.
Text Style | Markdown |
---|---|
Bold | **Bold** |
Italic | _Italic_ |
Bullet list | - Item 1\r- Item 2\r- Item 3 |
Numbered list | 1. Green\r2. Orange\r3. Blue |
Hyperlinks | [Title](url) |
- Newlines can be included with the body usingÂ
\n\n\n\n
. - Following is a code sample using ‘Markdown’ to customize Title and Body.
- Under ‘actions’ tag, url is pointing to an existing record.
function notificationWithCustomTitleAndBody() {
var systemuserid = "0758fd55-c2ca-ec11-a7b5-00224808dd66";
var notificationRecord =
{
"title": "Example of Custom Title and Body",
"body": "Maria Campbell mentioned you in a post.",
"ownerid@odata.bind": "/systemusers(" + systemuserid + ")",
"icontype": 100000004, // mention (Displays @ symbol)
"data": JSON.stringify({
"title": "[Potential Prospect](?pagetype=entityrecord&etn=raj_prospect&id=48f5d750-cbca-ec11-a7b5-00224808dd66)",
"body": "Here is a [Potential Prospect](?pagetype=entityrecord&etn=raj_prospect&id=48f5d750-cbca-ec11-a7b5-00224808dd66)",
"actions": [
{
"title": "View record",
"data": {
"url": "?pagetype=entityrecord&etn=raj_prospect&id=48f5d750-cbca-ec11-a7b5-00224808dd66"
}
}
]
})
}
Xrm.WebApi.createRecord("appnotification", notificationRecord).
then(
function success(result) {
console.log("notification created with custom title and body: " + result.id);
},
function (error) {
console.log(error.message);
}
);
}
- Up on execution End User receives notification as below.
Notification with a custom Icon:
- Within the notification, set iconType to Custom and in the body, include iconUrl with a value pointing to a web resource.
- “icontype”: 100000005, // custom
- “data”: “{ ‘iconUrl’: ‘/WebResources/cr245_AlertOn’}”
- The icon can be either an SVG or PNG file type.
- Following is the ‘notificationRecord’ object.
var notificationRecord =
{
"title": "Welcome",
"body": "Welcome to the world of app notifications!",
"ownerid@odata.bind": "/systemusers(" + systemuserid + ")",
"icontype": 100000005, // custom
"data": "{ 'iconUrl': '/WebResources/cr245_AlertOn'}"
}
- Notification with Custom icon looks as below.
Key points on Notification usage:
- If you don’t specify “ownerid@odata.bind” in ‘notificationRecord’ object, notification will go to the User who created Notification.
- Notification Polling:
- In-app notifications uses polling to retrieve notifications periodically when the app is running.
- New notification are retreived at start of the model-driven app and when a page navigation occurs as long as the last retreival is more than one minute ago.
- If a user stays on a page for a long duration, new notifications will be retrieved.
- Notifications appear in the notification center until the recipient dismisses them or they expire. By default, a notification expires after 14 days but your administrator can override this setting
- You can change in-app notification behavior by setting Toast Type to one of the following values.
Toast Type | Behavior | Value |
---|---|---|
Timed | The notification appears for a brief duration (the default is four seconds) and then disappears. | 200000000 |
Hidden | The notification appears only in the notification center and not as a toast notification. | 200000001 |
- You can change the in-app notification icon by setting Icon Type to one of the following values.
Icon Type | Value | Image |
---|---|---|
Info | 100000000 | ![]() |
Success | 100000001 | ![]() |
Failure | 100000002 | ![]() |
Warning | 100000003 | ![]() |
Mention | 100000004 | ![]() |
Custom | 100000005 |
🙂
Dynamics 365 and Microsoft Power Platform | Release planner
As the Dynamics Release Wave 1 2022 is being deployed this month, if you are planning for an upgrade of your existing system, Release planner tool (BETA) helps you to organize and plan for New and Upcoming features.
- To get started, first create an account. Alternately you can connect using your Work Account.
- Pick the feature you want to try add that to your plan by clicking ‘+ To my plan’.
- Click ‘Learn more’ to understand about the feature.
- Once you add the Features, go to ‘My Release Plans’ for collated list.
- Refer this article by Microsoft FastTrack Team on how to plan and approach the products release wave upgrades.
🙂
Canvas App | Edge Browser | Quick way to test the Apps Responsiveness
Its imperative to test the Canvas App’s responsiveness and on different devices to make sure the layout is responsive and intuitive. In this article, lets see how to test your Canvas App in different device orientations.
Steps to test the Canvas Apps Responsiveness:
- Open the App in Edge browser.
- Press F12 to open the ‘Dev Tools’ Pane.
- From ‘DevTools’ pane, click on ‘Toggle device emulator’ icon (Highlighted in screen below)
- Now you have the options to test the responsiveness using ‘Responsive’ option.
- Or pick any of the device option form the list. Use the ‘Rotate’ option, to test in Landscape orientation.
🙂
[Step by Step] Using JSLint extension in VSCode
In this article, lets see how to Install and use JSLint extension in VSCode.
What is JSLint:
- JSLint is a JavaScript program that looks for problems in JavaScript programs. It is a code quality tool.
- JSLint takes a JavaScript source and scans it. If it finds a problem, it returns a message describing the problem.
Install JSLint extension in VSCode:
- From the VSCode ‘Extensions’, search for ‘JSLint’ and Install.
- Next, we need to install ‘jslint’ Globally by running ‘npm install -g jslint’ command from Terminal.
- All the required files gets installed and Terminal looks as below.
Run JSLint on a JavaScript File:
- Open the JavaScript file, which you want to validate in VSCode.
- Open the Terminal and run ‘jslint {file_name}’ command. In my case, its ‘jslint HelloWorld.js’.
- Script violations will be listed in Terminal as below.
🙂
Power Apps Portals | Progressive Web Apps (PWA)
What is a Progressive Web App (PWA):
- PWA at core is a website built using web technologies but that acts and feels like an App.
- Users can install a PWA on any device be it a desktop or mobile from the browser or through app stores.
- Main difference between PWA and Web App is  a web app is designed to run inside of a web browser and cannot be installed on a device.Â
- Users can also pin the PWA app directly to the home screen on their mobile device.
Portals as progressive web apps:
- We can enable a Portal as a progressive web app (PWA), with native app–like look and feel, by using Power Apps portals Studio.
- This capability enables external and internal customers to use a portal as an app.
Steps to build a portal as a progressive web app:
- Connect to Power Apps maker portal.
- Select the Portal App and click ‘Edit’
- Portal opens up in In portals Studio.
- Select Progressive web app icon and set ‘Enable PWA’ option.
- Click on ‘Customize PWA’ to modify App’s details.
- Now click on ‘Browse Website’, which opens up Portal application along with ‘App available’ option.
- Click ‘Install’ to install Portal as a Desktop App.
- Post installation, you would get Portal as Desktop App as below. You have options to pin the App to taskbar or to Start.
Manage offline behavior:
- PWA offers support for a smooth navigation experience when the device being used is offline or disconnected from the internet.
- You can choose the pages within your portal that will be available offline (read-only), and a message page for the rest of the portal capabilities that haven’t been enabled for offline access.
- Under ‘Customize PWA’ pane, click on ‘Manage offline pages’.
- Select the Pages that will be available offline.
Refer documentation for more details.
🙂
Dataverse | New Auditing Features
Audit data is now stored separately from customer records so an organization’s audit log can grow to many terabytes in size without limiting available Database capacity.
Audit Retention Policy:
- In the ‘Admin Center’, on the ‘Environment’ page now we have ‘Auditing -> Manage’ option to set the Audit Retention Policy.
- Select one of the options from the dropdown to set the retention duration.
- Audit records are automatically deleted after the retention period is over, relieving administrators from the burden of deleting audit data manually.Â
- It is also possible to keep the audit log indefinitely by not specifying a retention period.
Free up capacity:
- With the new audit deletion options, Administrators can delete the logs of one or more audited tables, delete the user access logs, or delete logs up to a specific date in order to free up storage space.
Refer the docs link for more insights.
Power Apps Ideas (Preview)
In this article lets explore the Power Apps “Ideas” feature, which would be a blessing for all App Makers who write formulas using Power Fx.
As we know Power Fx is a programming language for low code, and makes it possible for hundreds of millions of people with Excel-like skills to add advanced logic to their apps.
What is Power Apps Ideas:
Power Apps Ideas is created to help everyone from the new makers to the seasoned IT pros to ease and speed up the formula authoring experience by using the power of AI models.
A quick example:
- I’ve the following Canvas App with Dataverse as Source. App has a Gallery control displaying ‘Department’ table.
- ‘Department’ table has a Date Time field called ‘Establishment Date’ and displaying values in MM/DD/YYYY HH:MM format.
- So what if I want to display ’27/12/2021′ as ’27 December 2021′. You need to form the syntax by yourself which could be tricky.
- Now lets see, how ‘Ideas’ works here.
- Select the date label from Gallery and select ‘Ideas’.
- Go ahead and type the format you are looking for. I’ve typed my desired format as “27 December 2021 5:30 AM“.
- Now click on ‘Get ideas’ button and you would get the formula for your desired format.
- Go ahead an click ‘Apply’, you get following notification, that formula expression has got updated.
- That’s the power of ‘Ideas’.
- Power Apps Ideas feature currently supports only Gallery and Data table controls for the Items property, and it now supports Microsoft Dataverse, Sharepoint List and Excel as connectors.
Methods to use “Ideas”:
There are two methods to benefit from Power Apps “Ideas” in your app.
Method 1: Transform natural language to Power Fx formulas
Method 2: Transform examples to Power Fx formulas
- This is nothing but the Date format example, I’ve explained in above sections.
- With Power Apps Ideas, you can now simply select that field, then in the ideas pane, enter your desired format, and press enter.
- One or a few formula suggestions will be popped out for you to select from.
🙂
Model Driven App | Modern advanced find
Finally the most awaited upgrade to the Legacy ‘Advanced Find’ Experience is coming up as part of 2022 Wave 1 release.
With Modern advanced find, you can access any table in a model-driven app through search and use advanced filters to explore the data easily.
Modern advanced find benefits:
- Explore any table in a model-driven app through structured search and filters. Edit columns and filter data to construct views that help you apply the right lens on your data easily.
- Choosing the right view to access is easier with the latest enhancement to view selector having the ability for you to search for a view.
- Managing views is simpler with personalization options to build your own set of views, hide views, and order them differently. Your personalized view list travels with you across all apps and all devices, online and offline.
- Collaborate with your team by sharing views easily and managing the views shared to you.
- All of the capabilities mentioned above will replace the legacy advanced find experience.
Availability Dates:
Enabled for | Public preview | Early access | General availability |
---|---|---|---|
Users by admins, makers, or analysts | Feb 2022 | – | Apr 2022 |
🙂
Power Apps | Business Rule | Set Field Value vs Set Default Value
While configuring Business Rules you might have noticed ‘Set Field Value’ and ‘Set Default Value’ Actions.
Though the ‘Set Field Value’ and ‘Set Default Value’ Actions look identical, there are following subtle differences.
Set Default Value:
- ‘Set Default Value’ only triggers on ‘Create’ event and does not trigger on ‘Update’.
- To understand this better lets go with an example, I’ve a ‘Student’ table with ‘Department’ and ‘College Fee’ columns.
- In my ‘Business Rule’, I am setting ‘College Fee’ field value to ‘10000’ using ‘Set Default Value’, when the ‘Department’ sets to ‘IT’.
- Now in my App, on Student’s ‘Create‘ form, the ‘College Fee’ field sets to ‘10000’ when the Department is IT as configured in Business Rule.
- If I open an Existing ‘Student’ record, and set the ‘Department’ to ‘IT’, ‘College Fee’ field will not get set to ‘10000’, which proves that ‘Set Default Value’ action defined in ‘Business Rule’ does not trigger on ‘Update’ event.
- One more key point is, ‘Set Default Value’ can’t override an existing field value.
- For example, on ‘Student’ create form, manually type some value in ‘College Fee’ and then change the ‘Department’ to ‘IT’ .
- This triggers ‘Set Default Value’ action, but the ‘College Fee’ value wont get changed to 10000 as there was already a manually typed presented in ‘College Fee’.
- Also, ‘Set Default Value’ does not have ‘Clear’ option.
Set Field Value:
- ‘Set Field Value’ triggers on both ‘Create’ and ‘Update’ of the record.
- Also, ‘Set Field Value’ has a ‘Clear’ option.
Hope these differences helps you while choosing between ‘Set Default Value’ and ‘Set Field Value’,
🙂