Monthly Archives: February 2018

PackageDeployer – failed to load the import configuration

When trying to deploy a package created using the PackageDeployer tool, you may run into this error:

1

“Failed to Load the Import Configuration : Config File Missing”

The error is, actually, self-explaining.. in a way.

Every package has two components: there is a dll, and there is a package folder. In order to deploy the package, as per the instructions here:

https://technet.microsoft.com/library/dn647420.aspx

You will start by copying the package folder and the dll to the PackageDeployer tool folder. So, when you start the PackageDeployer, it will look for all the package dll-s first, and it will allow you to choose the package if it finds the dll..

However, once you get to that step where the PackageDeployer is supposed to read package configuration, you’ll need to make sure your package folder name corresponds to what you have in the PackageTemplate.cs:

2

If you rename the folder while creating a package and leave GetImportPackagedataFolderName unchanged, PackageDeployer will actually be looking for the PgkFolder directory, and, so, that’s when you will see that error message above.

When a security issue is not a breach but still a pesky bug

 

What if you think you can update a record, and there are all the indications that you can, yet you try to change something and it just does not work?

In the example below(which I’ve originally discovered in 8.2.2, though the screenshots below are from 8.2.1), my test user seems to have “write” permissions, the form is not read-only in Dynamics, so I can modify field values on the form:

image

And yet, I’m getting an error message when trying to save the changes:

image

  <Message>SecLib::AccessCheckEx failed. Returned hr = -2147187962, ObjectID: c1d0e243-1e18-e811-9401-00155d00c101, OwnerId: 5c19475b-16f4-e711-93fe-00155d00c101,  OwnerIdType: 8 and CallingUser: 5c19475b-16f4-e711-93fe-00155d00c101. ObjectTypeCode: 10018, objectBusinessUnitId: 63746438-10f4-e711-93fe-00155d00c101, AccessRights: WriteAccess </Message>

So what happened?

“Security Test” is a new entity I just created

There is a security role that’s setting access to that entity like this:

image

Now here is the catch: that security role is not assigned to the user – instead, it’s assigned to the team, and my use is a member of that team.

image

And that team has  a role:

image

You would think my test user would have permissions to update the record. AccessChecker plugin in XrmToolBox seems to think so. Dynamics client side itself seems to think so.. But, apparently, something fishy is happening on the server side – it has its own opinion about who can actually update that record.

Interestingly, it’s all working fine if the record is assigned to the team instead. As a member of the team, my test user can happily update such records. I can even assign that record from the team to myself under that user account (because yes, the role has that permission). But, once the record has been assigned to me, it’s all over – there is nothing I can do with that record anymore.

BTW, the workaround for this is relatively simple – I just need to assign the same role directly to my test user.

Dynamics: Drawing activity sequence diagram

 

For the reasons not clear to myself, I was looking at the js-sequence-diagram library (https://bramp.github.io/js-sequence-diagrams/), and it occurred to me that I might probably use such a diagram to display the sequence of activities on the entity form.

And indeed.. here is what I ended up with:

image

If you wanted to try it yourself, just follow the steps below:

1. Download the solution file and import it to Dynamics (it was exported for 8.2 version, btw)

http://itaintboring.com/downloads/SequenceDiagram_1_0_0_0_managed.zip

This solution will deploy a number of web resources, and it will also add a new custom entity (Diagram Demo).

2. Create a new Diagram Demo record (you can do it using Advanced Find, for example)

image

3. Add a few phone calls to the newly created record

image

4. Reload the form (as in, use F5) and observe the results

image

As for the details on how it works, here is a brief explanation. First of all, there is nothing special about the entity above. It’s using a few web resources which are included into the solution, so, basically, it’s just a demo entity – you can do the same with any other entity.

To start with, you need to add ita_sequence_diagram.html web resource to the entity form:

image

You also need to create a multi-line text field and put it on the form (you can make it invisible of you wish)

image

Then, you need to configure onLoad event handler for the form:

image

– Add ita_/scripts/diagramsupport.js library

– In the onload event, use DrawSequenceDiagram function

– Pass two parameters: multiline attribute name and web resource name

image

Save and publish all.

The only remaining part is that you need to populate that multiline field with the “Sequence”. I used a workflow for that, and you will find it in the solution – it runs on create/update of the phone calls, and it just keeps adding text to the multiline attribute.. pretty strightforward:

image

It does not have to be a workflow – you can make something more elaborate (javascript, plugin, workflow.. or any combination of those). For the exact syntax of what should be stored in the multiline control, have a look at the js-sequence-diagram web site. Here is the link again: https://bramp.github.io/js-sequence-diagrams/

Have fun!

Entity ownership type: Business Unit

 

What the heck am I talking about? “Business Unit” ownership!? That’s not even a thing:

image

That’s more or less what I replied in the community forums to somebody who was asking about “business unit” ownership.

And yet, it does exist, even if it’s not something you can set up for your own custom entities:

image

You will find it on MSDN, too:

https://msdn.microsoft.com/en-us/library/gg309396.aspx

Entities that belong to a business unit. These entities have an attribute named owningbusinessunit.

Although, it seems even Microsoft itself got confused since they are mentioning owneingbusinessunit attribute which is NOT there for such entities. There is busineeunitid:

image

Owningbusinessunit is, actually, an attribute that you will find in the user/team owned entities. Such as an account entity, for example.

So what does all this mean, in practice?

Well, here is the thing.. When creating a team, or any other business unit – owned entity through the SDK, we have to set that businessunitid field. Otherwise, there will be an error:

image

An error has occurred: Expecting business column to be set for Creating business owned entities, business column is null

And, also, when setting up security, the minimum permission depth for such entities is “Business Unit”:

image

Every user in the business unit that owns the record will have access, and there is no way to make it more granular (user-level). Interestingly, that’s one of the caveats of the security model I used to notice occasionally, and, then, mostly used to dismiss as some strange quirk. Turned out there is an explanation.

Invalid User Authorization error

Was trying to enable data encryption in Dynamics and the next thing I knew there was an error message:

image

Invalid User Authorization

The user authentication passed to the platform is not valid.

It’s a rather vague message to say the least, so a quick google search revealed some links but no definitive answers. Lucky for me, this error was happening in the on-premise environment (although, where else would I need to enable the data encryption, right?) Even more, it was happening on my virtual machine, so I had full access..

Turned out the error message showing up in the windows event log on the CRM server was different, and, actually, much more useful:

Exception information:

Exception type: CrmException

Exception message: HTTPS protocol is required for this type of request, please enable HTTPS protocol and try again.

Now that’s straightforward. Yes, I did not have HTTPS..

Dynamics Portals: Aligning field labels to the left

 

When designing a form in Dynamics, we can specify, for each section, how field labels will be aligned. It does not seem to have any effect on how those labels show up on the portal, though, since they would always be displayed on top of the fields:

image

So how do we change label alignment so they that they move to the left? In other words, how can we achieve this:

image

Turned out it’s doable, and I’ll explain how. It might or might not be the best way of doing this, but it works.

First of all, have a look at this article by Andre Margono – it will explain why I had to apply my customizations via the portal itself rather than in Dynamics:

https://community.dynamics.com/crm/b/workandstudybook/archive/2018/01/08/dynamics-365-portal-when-the-custom-css-won-t-load

Actually, if you know why it would not work when done in Dynamics.. drop me a note.

Anyway, here is what I had to do:

  • I knew I had to apply different css styles, so I had to figure out the styles
  • Once I knew what the style are, I had to apply them to that particular section above (so the other sections still have “top” alignment for the labels)
  • The only way I was able to do it is by adding some javascript to the form that would find the section and apply updates style to the controls in that section

Here is the script:

$( “table[data-name|=’CONTACT_INFORMATION’]” ).find(“.control”).css(“clear”,”none” );
$( “table[data-name|=’CONTACT_INFORMATION’]” ).find(“.control”).css(“float”,”right” );

CONTAT_INFORMATION is the name of the section – you can find in Dynamics when looking at the section properties:

image

The rest is all about finding the table for that section and updating control styles. If you wanted to see the HTML structure, just use F12 option on any of the portal forms and see how they look like on the inside.

Now, thanks to that article by Andre Margono above, I quickly realized that I have to add that script to the form through the portal – somehow those updates were not coming through when done in Dynamics. Here is what I did:

Navigated to the page and opened the editor:

image

Used Options tab to add custom javascript (see above for the script code):

image

Hit the “Save” button, and here we go – for that section only, the labels are, now, left-aligned:

image

Failed to Generate Excel: An error occurred

I was trying to export data to an excel spreadsheet earlier today and ran into something that I have not seen before:

Failed to Generate Excel

An error occurred when Dynamics 365 tried to generate the Excel file. If this problem persists, contact your system administrator.

image

This was happening on a seemingly innocent view which had lots of columns in it. And, as you can see from the screenshot above, there is not a lot of additional information I was able to find in the log file (since there was no log file).

Was it about the total number of columns? Was it something else? It could not be because of the large data set since I did not have that much data..

What you see on the screenshot below is a reproduction:

image

There are only a few columns in the view, but if you try to export data to excel from that view, you’ll get exactly the same error. The same will happen if you try to download an excel template using that view.

Notice how there are two different fields with the same display label in that view. That’s exactly what was causing the error – changing the display label for one of the fields so that display labels become unique in the view solves the problem:

image