Posts

Showing posts from 2020

WebApi - Execute Bound Function (RetrievePrincipalAccess) in PCF

Image
I am current building PCF component that required me to determine if the user has specific rights to an entity before attempting to modify it. In order to do this I needed to figure out how to do an execute request for a Function bound to an Entity. The hardest part in doing all is really figuring out the parameters and parameterTypes you need to send with the request. This Microsoft article on how to Use Web API functions . The real takeaway from this article was pulling up the CDS metadata document for the system to determine the properties. Additionally the documentation for the Xrm.WebApi.online.execute function was also useful. https://<yourorg>.crm.dynamics.com/api/data/v9.0/$metadata This document contains the function name and their input properties. After finding the function in the document i was able to determine that I needed the following properties: entity, Target. This also gave me their Types which i could use i the parameterTypes section of the request. Th

PowerApps Portal - Users Can See More Than Their Assigned Web Roles Allow

Image
Anyone who has configured the PowerApps/Adx Portal before can tell you how complicated the security mechanisms can be to configure. It’s both easy to give users to much permission or not enough. Today we learned an important lesson regarding two fields on the Web Role entity. During testing of a new app a users told us that they could see the portal edit button as well as every web page in the system, OH NO! After spending about two hours digging through the Web Role, Website Access Permission, and Web Page Access Control records we finally realized that someone had updated the Authenticated Users Role field on the Administrator Web Role to True. This field and the Anonymous Users Role field gives every portal user of that related type the Web Role without having to directly assign the Web Role to the User/Contact/Account record. Which explained why we still had admin rights even though the test Contact we were using had zero Web Roles assigned to it. I hope this saves someo

Rotational Image PCF Component for Canvas Apps

Image
This image component allows you to rotate an image to any degree unlike the Canvas image component which only allows 90, 180, or 270 degrees. Having full rotation of the image can allow you to build things such a compass or custom gauges/indicators for your application. Installation/Usage Instructions Download

Launch A Canvas App In Model App From SiteMap

Image
Canvas PowerApps provide a great amount of functionality with little or no code. Many examples demonstrate how to open a Canvas App within a Model App on a specific record and pass the context of that record. What if you don’t want to open a Canvas App for a specific record? Let’s say you want to create a menu functionality for user to allow them to open other Canvas apps, or maybe you have developed a Canvas app which provides a file conversion function which doesn’t relate to records at all. It would be nice if we could easily load these types of Canvas Apps from the SiteMap. Here is how to get this done. This solution is based off the solution from Dynamict but I have made some improvement that allow you to utilize the same WebResource over and over again and also provides information from the originating Model App. Here is an example of a Canvas app I have created which will display a menu of items which the user can launch. The Canvas App is being called from the SiteMap

Pass Custom Parameters To WebResource From UIC SiteMap in Dynamics

Image
While working on creating a page to open a Canvas app full screen inside of a Model app I wanted to create a WebResource I could use over and over again. Most of the references I found showed the Canvas app name in the code which wouldn’t allow for code re-use. Instead I wanted to pass query string parameters to the WebResource so that it could get the name from the URL. The problem I ran into was with the new UCI interface and how it handles WebResources. After a bit of trial and error I found the trick was not using the WebResource type in the SiteMap editor but instead using a URL in the correct format and passing the parameters I needed within the Data parameters. Update- After working with the Maker Portal SiteMap editor I have realized that it will auto decode all of your Data parameters. Instead of using the Maker portal you will need to update the SiteMap using [XrmToolbox] or another XML Editor. Use XRMToolbox SiteMap editor to create your sub area. Do not use the Ma

Move from using Xrm.Page to formContex in UCI form based PowerApps WebResources

Image
The usage of Xrm.Page is currently deprecated, still available due to it’s high usage, but still deprecated. When will it go away, we don’t really know yet. How then can we use it’s formContext replacement within a web resource. Well Microsoft recently added a the getContentWindow() function to the context which allows us to get the actual content of a web resource. By adding an onload function to our form and utilizing getContentWindow() we can now call javascript on our web resource and pass it the formContext. Additionally you can add the context to the window object of the web resource so that the formContext can be used throughout the lifecycle of the web resource. Here is a quick tutorial on how to pass the formContext to a WebResource on a UCI Form. formContext in WebResource Form OnLoad Code // This should be in a script loaded on the form. // form_onload is a handler for the form onload event. function form_onload(executionContext) { var formContext = executionCon

Sparse Checkout with Git To Reduce Confusion

Image
If you would like to make updates to the Xrm types or any others in the DefinitelyTyped project on github you can find that cloning all the types can be a real pain. This is because a typical git clone will bring down everything and having over 6 thousand directories in this project can make thigns a bit slow. Startign with Git version 2.25.0 a new feature was introduces called sparse-checkout. This feature can be used to limit what is brough down in your git requests much like a .gitignore file, in fact it even uses the same filtering formats. The benefit of using this new feature is that you don’t need to update the .gitignore file which would be tracked in the changes. Instead these options are stored in your repo settings locally and will not show up as changes to your files. Let’s take a look! Here is my types directory in DefinitelyTyped clone. You can see that there are a lot of types, over 6K in fact. Righ now every time you do a pull it can take a little while because

Multilingual Support For PCF Calendar Control

Image
Multilingual support has been added to the Calendar component I recently shared . This works in both Canvas and Model apps. The following languages are now supported. English (default) German French Spanish Italian Dutch Russian Click Here to download the latest release of the component. Click Here to get the source code for this component. Check out these videos on how to get the control working in a multilingual setup. Canvas Apps Multilingual Setup Model Apps Multilingual Setup

Gotchas for PCF Code Components in Canvas Apps

Image
PCF Code Components allow developers to create their own custom interfaces utilizing Typescript and/or React. To learn more about the PCF Component Framework check out this article . Building these controls has been great in Model app but only recently could we also start re-using them in our Canvas apps. If you want to learn more about how to add your PCF Code component to a Canvas App check out this article from Microsoft . Now that these controls can be utilized within Canvas Apps there are a few things to watch out for. Some of these are bugs that should be fixed when this all comes out of Preview and into General Availability. ControlManifest.Input.xml The ControlManifest.Input.xml file is where you define your component information and all the properties associated with it. Below are some gotcha that will cause you errors when attempting to deploy your component into a Canvas app. Be Careful of XML Escape Characters When defining your component it’s important to add desc

PowerApps Calendar Control

Image
This calendar control was built off of React Big Calendar . The calendar can be used to display events with or without related resources. This control has been designed to work in both Canvas and Model apps. Because of the differences in those types of applications there are some differences in how you utilize them in each app. Canvas If you want to utilize resources in Canvas you will need to use a collection as the data source. If just showing events with no resources a simple CDS dataset can be used. There are output parameters that are defined in the app which will pass back data when an item is clicked on, an empty time span is selected, or the calendar range has been updated. These output parameters will allow you to create your own functionality in the Canvas app for updated or creating records. Model Clicking on and event will open the record for editing. Clicking on an empty timespan will open a new record form, and will pass in the start, end, and resource field d

Bing Maps PCF Control

Image
Bing Maps PCF Control Overview This PCF control allows you to display information for a view that contains latitude and longitude information within Bing Maps. The Info Box for each pushpin that is created on the map also gives you the ability to open the selected record. Additional Features Map will default to a bounding box defined by the location data being shown. Will work with dataset that are 5k+ in size. Installation Usage After you install the solution into your system create a new view and add the custom control to the view. Ensure you add the required fields to the view and any filter you want. After you create the view Publish the customizations and navigate to the new view. The video below provides additional details. Download The latest release is always available here.

Utilize Customized npm Package from GitHub Branch

Image
Utilize Customized npm Package from GitHub Branch When working with npm libraries there are times you find bugs or want to add functionality to a library. You could just modify the files locally and run the application but this gets tricky when you go to deploy an application and it does an npm install which doesn’t include your changes. If the project is out there on GitHub there is a better way. Fork the project on Github to your account. Create a new branch from your fork. Fix the bug or add the functionality you want. Uninstall the original npm package by opening a terminal within the directory of your project and running the following command. npm uninstall <package-name> Example npm uninstall node-simple-odata-server Install the npm package from your Forked branch using the following command from a terminal within your project directory. npm install --save <your-github-user>/<repository-name>#<branch-name> Example npm install --save rwils

Azure Maps PCF Control

Image
Azure Maps PCF Control Overview This PCF control allows you to display information for a view that contains latitude and longitude information within Azure Maps. The Popup Box for each point that is created on the map also gives you the ability to open the selected record. Additional Features Utilizes a central configuration entity for authentication which means not having to update multiple controls if authentication changes. Map will default to a bounding box defined by the location data being shown. Will work with dataset that are 5k+ in size. Download The latest release is always available here.

Custom Grid/Subgrid Using Office-UI-Fabric DetailsList

Image
Custom PCF Grid/Subgrid Using Office-UI-Fabric DetailsList Allows you to simulate the out of the box Grid and Subgrid controls using the Office-UI-Fabric DetailsList control. It was built to provide a springboard when you need a customizable grid experience. This component re-creates a mojority of the capabilities available out of the box in less than 300 lines of code and demonstrates the following: Using the DataSet within a React functional component. Displaying and sorting data within the Office-UI-Fabric DetailsList component. Rendering custom formats for data with the DetailsList component such as links for Entity References, email addresses, and phone numbers. Displaying field data for related entities. React Hooks - the component uses both useState and useEffect. Loading more than 5k records in DataSet. Retaining the use of the standard ribbon buttons by using the setSelectedRecordIds function on the DataSet. Detecting and responding to control width updates.

Use Dynamics WebAPI to get Record Count

Use Dynamics WebAPI to get Record Count When working in an environment where tools like XrmToolbox are not available or allowed getting a total record count can be a real pain sometimes. One way of doing it just using the browser involves using the Dynamics WebAPI. This came in handy last time we were doing a data load on our production system and wanted to see the status of how many records had been imported. Small Data Set ( < 5k) If you are trying to get the count for 5,000 or less records. you can do a simple count on the data. Format /api/data/v9.0/<Entity Set Name>/?$count=true Example /api/data/v9.0/contacts/?$count=true Data Returned {"@odata.context":"https://org.crm.dynamics.com/api/data/v9.0/$metadata#contacts", "@odata.count":3 ,"value": Large Data Set ( > 5k & < 50k) If your record set will have 5k or more you can utilize the webapi by creating a FetchXml aggregate query, this does have a limitation of

Use Dynamics WebAPI to get LogicalName or ObjectTypeCode for Entity

Use Dynamics WebAPI to get LogicalName or ObjectTypeCode for Entity If you need to get the LogicalName or ObjectTypeCode of an entity in your Dynamics environment you can utilize the WebAPI to get the metadata. If you have the LogicalName of the entity you can use this url. Format: <Dynamics Url>/api/data/v<Version>/EntityDefinitions(LogicalName='<LogicalName>')?$select=ObjectTypeCode Example: https://org12345.crm.dynamics.com/api/data/v9.0/EntityDefinitions(LogicalName='account')?$select=ObjectTypeCode Data Returned: {"@odata.context":"https://org6744e6cd.crm.dynamics.com/api/data/v9.0/$metadata#EntityDefinitions(ObjectTypeCode)/$entity","ObjectTypeCode":1,"MetadataId":"70816501-edb9-4740-a16c-6a5efbc05d84"} If you have the ObjectTypeCode of the entity you can use this url. Format: <Dynamics Url>/api/data/v<Version>/EntityDefinitions?$filter=ObjectTypeCode eq <ObjectTypeCode