Tag Archives: FabricUI

Making a better User Experience with PowerApps Component Framework from sketch – Part 4 – The Final Showdown

Published / by AK / Leave a Comment

You can read previous post Part 1, Part 2 and Part 3.

Seeing is believing

It took me 2.5 days to learn and figure out the design and new technologies I need to build the component.

Less than half a day, the mock version of the component was completed. The component was loaded on the form, the dialog was shown with the mock file list, the Flow was triggered to attach a hard-coded SharePoint file to an email as an attachment.

Now, I can prove the team that the PCF control works. I can show it to users how the component can change their life drastically.

When users saw the new UX, it just blew away them. They just forgot the inconvenience with the out-of-the-box user experience. We shot down Top 1 issue from their bounty list.

Keep yourself connected

Though the mock version was smooth, there were a few issues (as expected) I faced. When I tried to use WebAPI in PCF, it always return null. I checked my old PCF which used to be work. It was not working anymore. I looked at other PCF examples from the community. All looked same as mine. Mine was not working. I had no clue.

So, I reached out Natraj (God Mode of PCF). He kindly showed me the direction. It turned out PCF team had introduced <feature-usage> tag in manifest. I had to include WebAPI feature in manifest file to use WebAPI. It was a life saver.

A blocker? Reach out to the community.

You don’t have to be alone solving the issue.

Coming to the end

Just over 1 day of building and trouble shooting, I had a fully working version of the component. In fact, the total build time was less than the initial design and exploration.

If you ask me “Would you spend more time thinking and playing than actual building?”, my answer is “Always”.

I encourage my colleagues to spend more time exploring than completing tasks. Completing the task is the last thing I worry. To me, understanding fundamentals and visualising the process are more important than just completing the task. Once you fully understand it, the rest is a piece of cake. You don’t need to look back. You can keep moving forward.

Limitations or future enhancements

There are many limitations and a few things I couldn’t include in this first version.

  1. Support sub-folder in SharePoint – The component does NOT currently support the navigation of sub-folder in SharePoint. I had the working FetchXml query and will add it in next version.
  2. Support attaching documents from Notes – I want to allow users attaching from Notes of an associated record, similar to SharePoint documents.
  3. Support local file attachment – This will make the component one-stop shop for attachments. You can attach files from SharePoint, Notes and local files.
  4. A managed solution package (with potential AppSource)

Configuration

After I posted the component in LinkedIn, a few people reached out to me how to configure the component and its Flow. I had privately responded to them.

The component accepts 3 properties

  1. Regarding Id – Can be bound to any text field. However, I recommend creating a separate text field as I need to update it’s value to trigger onChange event in Dynamics to refresh the grid. Currently, it is the only supported way to refresh the grid.
  2. SharePoint Site URLs – You can include multiple site collection addresses with comma separated value. For instances, https://mysite.sharepoint.com/site1, https://mysite.sharepoint.com/site2
  3. API/Flow URL – The URL of Flow end point. It will look like this “https://prod-19.australiasoutheast.logic.azure.com:443/workflows/…invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=…&spsite={0}&spfilepath={1} . Get my Flow here. Once you imported the Flow, copy the HTTP URL from the trigger. Then, append the URL with &spsite={0}&spfilepath={1} and set it as property value.

Last step is to hook up JavaScript to refresh the grid. Create a JavaScript web resource or update the existing one with the following script.

function refreshAttachmentGrid(executionContext) { 
var formContext = executionContext.getFormContext();
var attachmentGrid = formContext.getControl("attachmentsGrid");
attachmentGrid.refresh();
}

Then, add the web source to the Email form and add onChange event on the attribute you bound with PCF to call refreshAttachmentGrid function.

That’s all you need to configure to use the component.

I hope you enjoy this mini-series of blog. You can read Part 1, Part 2 and Part 3.

I will be back with another cool PCF that works in both model-driven apps and canvas apps. Stay tuned. Bye for now.

Making a better User Experience with PowerApps Component Framework from sketch – Part 3 – The Slow Start

Published / by AK / 1 Comment on Making a better User Experience with PowerApps Component Framework from sketch – Part 3 – The Slow Start

You can read previous episode Part 1 – The Problem and Part 2 – The Sketch.

The Slow Start

I always take time to figure out the suitable frameworks and libraries, try them out and learn them, as the first stage, before building. That makes me a slow start. Sometimes, notoriously slow. It is, to me, worthy as it will give me an extra boost from the mid stage.

List to free you up

Firstly, I listed down main questions/challenges in this problem

  1. Office UI Fabric – How would I use? Where would I learn? How would I test?
  2. Popup dialog – Which dialog should I use; PCF Popup service or Modal from Fabric?
  3. Getting document lists from SharePoint – How would I retrieve document lists from SharePoint?
  4. Getting a file content from SharePoint – How would I read the file content from SharePoint? Using JavaScript or custom WebAPI or Microsoft Flow?

Intelligence == Liability

This is something I learned during my early day with Test Driven Development (TDD). Smart people do not write unit tests on their code, because their code always work. By the time, they write unit tests on their code, it is eventually too late.

The same concept

Writing down a list of things you need to do can be challenging. It can be seen as waste of time, lack of creativity and extra works.

To me, it is the total opposite. With list, you don’t need to memorize what you need to do, thus it frees up your brain. As a result, you can shift your focus to new stuffs for boosting the creativity.

UI Fabric

It is a preferable choice in creating user interface that mimic Microsoft Office products. Besides, it is built with React. No brainer here. But the problem is I had never used UI Fabric before.

I went to UI Fabric and started playing with controls and styles.

The best thing about UI Fabric documentation is you can export the sample code to CodePen and play around with it. It was an ultimate time saver, as I didn’t need to setup UI Fabric in my machine.

I learnt how to use several components like

  • Detail List for showing files from SharePoint
  • Icons for displaying appropriate file icons so it is visually appealing
  • Scrollable Pane for making the popup dialog compact even with a long list of files
  • Search for allowing users to search files so they don’t need to scroll through
  • Button for triggering a logic to attach files from SharePoint to Email attachments in CDS
  • Progress Bar for informing users attaching files is in progress so they know it is doing something

Popup dialog

First, I looked at Popup service in PCF. I felt its implementation is not very friendly plus minimal documentation. It would be perfect for a simple dialog.

I turned into Modal component in UI Fabric. Since I will be using other UI Fabric components, I decided to stick with Modal from Fabric. Plus, I can test it CodePen whereas I have to setup a PCF project for Popup service.

Getting documents from SharePoint

You cannot retrieve documents from Advanced Find although you can see it in the query.

SharePoint Document in Advanced Find
SharePoint Document in Advanced Find

So, what did I do? I used Developer toolbar and inspected the network traffic. It gave me FetchXML I needed and the response I can work with.

Getting a file content from SharePoint

I tested reading SharePoint file using “fetch” library”, I immediately hit into CORS issue.

Therefore, I had to develop a custom WebAPI. I decided to use Microsoft Flow as a HTTP endpoint, since Microsoft Flow already has the out-of-the-box SharePoint connector.

Slow is smooth. Smooth is fast.

United States Navy SEALs

Up to this point, I spent almost 2 days to figure out and play around with most components I needed to use. I hadn’t written a single line of code in the PCF project.

Now, I asked myself the same question.

Am I ready to build? Definitely, YES.

Yes, I am ready to build the component by myself. Besides, I am ready to give a definitive guide to others for build the component I want.

Next, I will share you how long it took me to build a working component (excluding these 2.5 days:0.5 day of sketching and 2 days of learning). Stay tune for the final episode.