Tip #1159: Run your script after business rules

Dynamics 365/CRM customizations inflicted by a customer are always fun. How can I tell their customizations apart? Easy, by the new_ prefix. Where things get really complicated if the customer later asks you to do something they are not sure how to.

Just recently I was asked to stop couple fields from being locked if the user has one of the preconfigured roles. The challenge was that those fields were locked as a result of elaborate concoction of business rules, the business rules cannot be selectively applied by role and there is no condition in the business rules that would allow role filtering. Sigh.

Option 1

Duplicate the form, scope the business rules to the original form only and grant form access only to the selected roles. It will kind of work but maintenance of multiple forms is no fun and I bet I would have been asked to automatically switch the forms.

Option 2

Rewrite rules as javascript. No, thanks, I choose life.

Option 3

Add straightforward script executing onLoad and onChange unlocking those fields for the selected roles. That sounds good. Sleeves rolled up, script written, wired in, and … no worky. Because, even though there is no definite documentation on the order of the execution, business rules tend to get in last, after all the custom event handlers have been accounted for.

The workaround is surprisingly simple. Javascript, as implemented by all browsers, is event-driven but single-threaded. That means if we create an event around our function, it will push the call into the queue behind all those pesky business rules scripts.

function doUnlockControls(fc) {
  fc.getControl("new_foo").setDisabled(false);
  fc.getControl("new_bar").setDisabled(false);
}

function unlockControls(fc) {
  if(userHasAnyRole(['Role 1', 'Role 2']) {
    setTimeout(doUnlockControls, 0, fc);
  }
}

function OnLoadAndOnChanged(execContext) {
  var formContext = execContext.getFormContext();
  unlockControls(formContext);
}

setTimeout function creates an event that gets pushed to the queue and executed after the business rules scripts, even with the timeout set to zero. So this workaround works if you have some code that you have to execute after the business rules. But, as with any unsupported workaround, use at your own risk, contains small parts, choking hazard, swim between the flags. Not tested on animals, children or CRM.

(Facebook and Twitter cover photo by Melanie Pongratz on Unsplash)

Tip #1158: Be very selective in the grid

As I was discussing the workaround for the N:N regression bug, I noticed that some of the users, especially those switching from classic UI, are somewhat confused how to disassociate the records in the Unified Interface.

The UI can be, indeed, a bit confusing, especially when the viewport is small and the subgrid switches to the card view. Many times I’ve seen users pressed Delete while they really meant Remove.

This is the context menu and this is exactly what you don’t want your users to do:

Delete Contact in N:N grid

Instead, use … > Select
Select N:N records

That will switch UI into select mode and, once one or more records are selected, the … will now contain the coveted Remove

Disassociate contact

The other good business practice in my books is to completely revoke Delete privilege on contact (and many other) records, and teach users to deactivate contacts instead. That preserves the integrity of the business data and enables a quick “recovery” process, if a mistake is made.

(Facebook and Twitter photo by Nathan Dumlao on Unsplash)

Tip #1157: Do not delete system components

When you provision a Dynamics 365 instance, it comes with a number of system views that may or may not apply to your scenarios. Take, for example, Contacts: No Campaign Activities in Last 3 Months. If you are not into marketing, why would you need one? As tempting as it could be to just go around and whack the system views you have no need for, DON’T.

If another solution, e.g. Dynamics 365 for Marketing, expects this view to be there, then the installation of that solution will fail.

Shan “Smoke ’em” McArthur, Principal PM at Microsoft, explains:

I do want to call out that I notice that many customers attempt to ‘clean up’ their CRM environment by deleting components they think they don’t need that are brought in via system solutions or ISV solutions.  We have a mechanism for them to hide forms and views and that is much more preferred to deleting the view as it is very difficult to bring back a deleted view to avoid future updates from the solution owners. It would be nice for customers to know that they can mark views and forms as inactive instead of deleting them – unless they are the owner of those forms and views.

Moral of the story: if you want to get rid of a system form or a view, deactivate them. Or consider building an model-driven app where you can select exactly which views and forms are available to the users.

If you did the unspeakable and deleted one or more system components, and there is no backup for you to restore, log a case with support who should be able straighten up your instance.

(Facebook and Twitter cover photo by Kyle Glenn on Unsplash)

Tip #1156: Locked fields out of the box

Long time ago Stefan Strube sent me this tip, I filed it away and forgot all about it (sorry, Stefan!). Until last week, that is, when I started new deployment and customer had specific need for couple rollups on account entity. Good news was that those rollups are out of the box: opendeals and openrevenue, so I dropped then on the form and left it be. Bad news was that the testers immediately complained that they can’t see these fields at all.

locked-fields

What the?

Tip from Stefan to the rescue! These rollup fields are Field Security enabled by default, therefore only the admins will see the calculated values but all other users will not.

To check what’s going on out of the box, create a new field security profile and, presto:

protected-fields

These are OOB fields that have field security enabled on them.

As per the original tip, if you want to make these fields available to (a group of) users, create a Field Security Profile for this and set Read privilege to Yes. Update and Create are not available simply because these fields are rollups. You probably noticed an interesting case of sharepointemailaddress field – Read privilege cannot be set at all. This is because the metadata flag CanBeSecuredForRead is false, meaning “You shall not deny user reading this field”. Oh, well, nobody knows what this is field is for, anyway. Wait a minute, turns out I do!

(Facebook and Twitter cover photo by Markus Spiske on Unsplash)

Tip #1155: The Clock is Ticking on Your Endpoint

This is very much a collaborative post. Leon had a first go at it, George threatened to rip it all apart if posted because of the tiny technical inconsistencies. The verbal abuse discussion ensued, links were cross-checked, and now we have this.

We have known for a while that the Dynamics CRM 2011 endpoint is deprecated and, if we are using it to access the Dynamics 365 organization web service, we need to update our code. The linked article says

The 2011 endpoint will be removed some time after the release of Dynamics 365 version 9

Given this is a little vague, Leon raised it at the CRMUG Summit EMEA in Dublin earlier this year. At that time it was confirmed by Microsoft that the 2011 endpoint will be around at least until the release of v10.

So when is v10 coming out? At the time we did not know. Now looks like we do! The October ’18 Release Notes are out. This means that, assuming Microsoft stick to their schedule, and assuming that October release will be, in fact, version 10, it will be out in October this year. What does this mean for your Dynamics implementation?

No one can express it better than Matt “Platform Deity” Barbour (this is somewhat abridged and modified version):

  1. The deprecation does not mean that the endpoint will be removed AT version 10. Microsoft has a lot of metrics for various things including the SOAP usage and continuously evaluates the consequences of removing something as fundamental as the endpoint.
  2. The Organization Service (the IOrganizationService Implementation), used in the CrmServiceClient and Plugin\Workflow system is NOT deprecated. For folks building plugins, using the IOrganizationService is the right way to go, and will remain so for the foreseeable future.
  3. With regards to the CrmServiceClient, nothing changed since the deprecation notice.

    We plan to provide updates to the Dynamics 365 SDK assemblies and tools over the next several minor releases, retargeting them to use the Web API instead of the 2011 endpoint.

  4. Which approach to use?
    • If you’re building plugins, build around IOrganizationService and other SDK assemblies.
    • If you’re building using the .NET framework, the CrmServiceClient is the way to go.
    • If you’re building on non-Microsoft platform or .NET Core\Standard [at the moment], the Web API is the way to go.

Note that Web API is not explicitly mentioned in #2. For new developments you may want to consider Web API as well but do not expect the same level of support as exists for .NET, e.g. strong type support, authentication wrappers, diagnostics and such.

Why? Because OData, as an industry standard, has many different ways and methods folks can adopt to do this. Each offering their own flavor of features and capabilities to support the needs to the technology that is implementing it.

I’m sure that with time we will see 3rd party Web API wrappers emerging (and they do already exists) that will make development easier, and purists and minimalists happier. 

Call for action

Check the code that is talking to the Dynamics 365. Ensure that the code is using either Web API or SDK assemblies. This does not mean just plugins but anything integrating to Dynamics. It may be integration to another system or a custom web form application. All interactions need to be checked and if they are explicitly replying on the 2011 endpoint, bring them up to standard. The clock is ticking.

(And as painful as it is for me and many others, we’d have to admit that George was rightalmost two years ago.)

Tip #1154: When Unified Interface misbehaves

We know that Unified Interface is not yet on par with the classic UI. Some things are not yet there, some things will never be there because there are better ways to achieve the same results.

Since Dynamics 365 is a continuously updated beast, sometimes bugs and inconsistencies make their way into a working feature. The other day I was asked by Brent “I am a little afraid of what’s to come” Howard why, after the latest update for the Unified Interface (1.3.230-180801-000211) has removed the ability for users to Associate records in a N:N relationship. (To qualify: not just any relationships but the ones that involve contacts – t.j.). The workaround is for the user to switch out of the Unified Interface and use the classic UI however most of their work force are using the mobile interface and are only very basic PC users.

Walkthrough

When you add N:N relationship between an account and a custom entity, say, foo, and then add a subgrid to the account form, the menu looks like this:

N:N grid with Add Existing

That allows to associate an existing Foo record and create a new one if needed (association side panel has a +New button).

If you add a new N:N relationship between account and contact entity then subgrid menu will look like this:

N:N grid without Add Existing

Note that Add Existing is just not there.

Workaround

Kudos to Brett for finding the workaround that involves, you guessed it, poking around with the Ribbon Workbench.

  1. Create a small solution that includes contact entity and application ribbons.
  2. Open either standalone Ribbon Workbench or as part of the XrmToolBox and load that solution
  3. On the SubGrid ribbon you’ll find two Add Existing {0} buttons, select one with the Id of Mscrm.SubGrid.contact.AddExistingAssoc
  4. It’s a system button so nothing will show up until you right mouse click and select Customise Command (note that Scott is from UK and sneaked in correct spelling of the word Customise)
    Customise command for system button
  5. That will light up Solution Elements panel where you’ll find Mscrm.NotUci enable rule. The rule looks like this
    The rule that removes the Add Existing button
  6. Right click > Delete (you do have a backup, don’t you?)
    Delete the enable rule
  7. Publish the solution, then reload the form and here we go:
    N:N contact grid with Add Existing command

If I have to guess, the regression bug is in Xrm.Internal.isUci function from the Marketing/ClientCommon/Marketing_ClientCommon.js web resource but let’s wait and see how it’s going to be fixed.

(Facebook and Twitter cover photo by Tomas Sobek on Unsplash)

BAD Masterclass

CRM Tip of the Day and 365.Training present Business Application Developer (BAD) Masterclass

What is it

The Dynamics 365 Power Platform has a rapid release cadence and with that come the new features, new developments, and new challenges.This is your chance to get your hands on the new technologies and learn the new stuff before anyone else. Hear the news from the latest conferences and what does it mean for Business Application Developers.

Who’s behind it

BAD Masterclass is a brainchild of  yours truly, George Doubinski, founder of CRM Tip of the Day and CRM.Audio and David Yack, Microsoft Regional Director and author of https://xrm.tools.

What’s in it for me

Unlike any of the courses and trainings you find, it’s not about what you can do in Dynamics 365 world today, it’s about what will you use tomorrow. Aimed at proficient developers at the level 300-400, it covers new and upcoming technologies, trends, and best practices you need to create Business Applications for the future. It is delivered as a mix of presentations, talks, discussions, hands-on exercises, and developer challenges, all packed within 2 days of in-class learning.

This class is for all you experienced Dynamics 365/CRM developers who want to take your skills to the next level.

Where

    • 24-25 May 2018 Milan
    • 28-29 May 2018 Amsterdam (sold out)
    • 31 May-1 June 2018 London (sold out)
    • 4-5 October 2018 Toronto – Register!
    • 10-11 October 2018 Colorado – Register!

Agenda

Day 1

  • Introducing Masterclass and CRM Tip of the Day BAD Challenges
  • What’s new and what’s old for the Developer
  • Solution Dependencies/Light Weight Solutions
  • Work time – Solution Challenge
  • Advanced Data Modeling
  • Virtual Entities
  • Work time – Virtual Entity Custom Provider
  • Client: TypeScript, PowerApps Control Framework, Hosted Canvas Apps
  • Work time – Typescript

Day 2

  • Themes from the latest conferences and announcements, and what does it mean for Business Application Developer
  • Authentication Essentials
  • Work time – Authentication
  • Azure Building Blocks Overview
  • Advanced Logic Apps and Flow
  • Work time – Azure
  • Custom Connectors
  • Work time – Building a Custom Connector
  • Wrap up: developer challenges, cool things and giveaways

Note: Agenda is subject to change

Tip #1153: When Upgrading, Consider the Whole Ecosystem

It is that time of year when people turn their thoughts to upgrading; the October 18 release has been announced and for those on Dynamics 365 Online v8, the clock has started. I was recently with a client who had a pretty typical setup. They had Dynamics 365 Online, NAV 2016, and an online shopping system. They asked me about the looming upgrade of Dynamics 365 and if they should be concerned about anything.

I raised the usual recommendations regarding upgrading Dynamics (backing up, doing it in a non-production environment first etc.) but then we got talking about the rest of the setup. Firstly, they were using the NAV 16 Connector to talk to Dynamics but it was not working 100%. They had custom fields in NAV which never made it to Dynamics and this compromised the reporting in Dynamics, limiting its usefulness to the sales team. Knowing the NAV 16 Connector was not an on-going concern for Microsoft (and that it never handled custom fields well), the obvious choice was to move to Azure ASAP.

So we should upgrade NAV 2016 before the end of the year, right? Well there was another problem. NAV 2016 was connected to the online shopping system via a proprietary integration piece. If NAV 2016 got upgraded this would break and the online shopping system would need to be upgraded. The problem? the estimated cost to upgrade the online shopping system was six figures. Coming up with that in the next few months would be tricky.

The end solution? Dynamics 365 would go first. This was relatively low risk given the limited customisations and should not affect the other components. Next, rather than upgrade NAV 2016, I recommended they get either a custom NAV 2016 Azure Connector developed to meet their needs or, if this was too difficult, develop a custom integration piece. Initially this could cover the custom fields missing from Dynamics 365 and then, once it proved successful, expand to cover the entities and fields of the incumbent Connector if they wanted to manage it in one place. I warned them if a custom integration piece was developed it would likely be thrown away in the future as they move to using more Azure components but it was a reasonable short term measure until they upgrade the shopping site and NAV 2016.

The moral of the story? Consider the full ecosystem when looking to upgrade and the consequences it might have. Also, while there may be an obvious solution such as getting off of the NAV 16 Connector, consideration of the bigger picture may sometimes require short term compromise, rather than perfection.

Tip #1152: Attachments to Dynamics 365 Notes

Flow is great but can be frustrating at times, as Jerry “Once tipster – forever tipster” Weinstock has discovered when trying to add attachment to a note in Dynamics 365.

This is his story

File uploads to OneDrive etc work great. Files attach to emails with no issue. A super slick Flow feature! I am trying to get a photo to be an attachment to a Dynamics 365 Note. (Note creation works perfectly)

clip_image002

I have tried both the Dynamics 365 Create Record action and the new CDS Create Note (annotation) action. Both essentially return the same failure file type message when I try to open the photo.

clip_image004

I have tried wrapping it in in an expression, no positive results. Am I trying to do something that can’t be done currently or just not doing it right?

Help is on its way

Turns out, Create Note (annotation) action is not the right one to use in Flow, Dynamics 365 Create Record is the way to go. According to Stephen Siciliano (Principal Group PM Manager at Microsoft, in case you were wondering):

Specifically, you will need to base64() encode the data that you’re passing to the Document property. To associate it with a given record populate the Regarding field:

clip_image002

Tîpp Jäår $0.02

So, in short, create note attachment in one sweet action and use base64 to make sure that the content is right.

(Facebook and Twitter cover photo by DiEGO MüLLER on Unsplash)

Tip #1151: Name that web client

With so many upcoming and constantly changing features in the world of Dynamics 365/CRM, it’s no wonder that even the best of us are getting confused when it comes to naming things.

Regardless of what interface is chosen, it all looks like a web client Mark “Globetrotting Kiwi” Smith:

Currently what I hear used is Unified Interface or UCI is for the new interface and the old interface is the Web Client.  This seems strange to me as both interface still run in a web client or am I missing something?

Ask and you shall receive. Clarification came from Shilpa Sinha, Principal PM at Microsoft:

Unified Interface is the external name for the new interface and we are referring to the old interface as Classic UI.

So here you go, folks, they are both web clients but if anyone asks, it’s a new, exciting, and highly performant Unified Interface vs fully-featured but at some point becoming thing of the past Classic UI. As we know, classic stuff is perpetually in vogue with some people and, as with any antiques, it will get very expensive with time.

(Facebook and Twitter cover photo by Adrian Korte on Unsplash)