tisdag 28 april 2015

Import Data privileges and appointment errors

Data import is indeed a powerful tool that will allow you to update many records at once, however to my great surprise the security settings to allow a user to import data is not completely simple to understand.
Next, when you get a log full of error messages you suspect something's wrong...


The first problem I was facing this time is to import data that has been exported from CRM. This seems to be a pretty straight forward operation, and it should be, however the security settings makes it pretty much everything but simple.

The user that was going to do the import had pretty high level of rights to do things in the system but when she imported data that had been edited in excel after export the data import job was suspended in limbo saying "imported" (or something similar) with the job halting with an error saying "Failed to get priv user group information. k = <guid> privUserGroupId: <guid>, localSystemAdGuid: <guid>, Exception: System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"

This made me look at the AD and the PrivUserGroup,even though I suspected that it wasn't the actual problem, no luck there. As I suspected that this wasn't the problem I tried to import the file using a sysadmin account which actually worked.
As I was done troubleshooting I tried to find the correct security settings to import files and found them on the Microsoft forums. The winning lineup is the following:

* Data Import (all)
* Data Map (all)
* Import Source File (all)
* Web Wizard (all)
* Web Wizard Access Privilege (all)
* Wizard Page (all)

You can probably get away with BU rights to be able to import stuff to your own BU. The entire thread can be found at Microsoft forum. It's a good thing that these things are simple to solve, and that the error message isn't something like "User X is missing security right Y", that wouldn't make it as interesting.

Moving right along with the next issue which I also was facing at the same customer. They had a LOT of error messages in the trace logs saying  "
>Crm Exception: Message: recurringappointmentmaster With Id = 00000000-0000-0000-0000-000000000000 Does Not Exist, ErrorCode: -2147220969". This made me slightly nervous considering that the customer also have had some issues with performance that we are investigating at the moment. Now, to make things clear, we are NOT being nice to the appointment entity with some heavy, but supported, customizations so I wasn't exactly chocked to see errors being thrown here.

I want to say that there doesn't seem to be a problem with the appointment entity since it's ok to create appointments most of the time, but we've also seen an alarming amount of "hey something's wrong, you want to send data to Microsoft?" boxes so it might have been something that wasn't optimal. Today I was helping one of the users with monitoring what the system was up to when she was doing her work so I had some time to sit down and have a look at the logs, which is one of the best things I know.
This error message was pertty common as usual and I started looking for others that had this issue but nothing obvious came up so I thought what happens in a completely vamilla system, something I haven't trie yet.
I had a CRM that I hadn't modified anything, CRM 2013 SP1UR1 on premise that I popped up an appointment form in and entered "test" in the topic field, lefter everything else as is (some dates but that's it) and saved. This gave me the exact same error in the trace logs.

This ticked me off a bit. Microsoft actually ships a system, in it's fourth or fifth iteration of that version and it truly SPEWS out error messages in the trace log when you create an appointment. That is not OK.

If you get a lot of errors with recurringappointmentmaster with ID = empty guid, that's how CRM is supposed to work. Sorry to say this though.



Rickard Norström
Developer at CRM-Konsulterna
www.crmkonsulterna.se

onsdag 22 april 2015

This is a draft post that I never finished, still the information is quite useful so I hope it helps someone. Read it as "a couple of months ago" :) //Rickard
 
It's been a while since I published something here, seems as the days are too short. Today I will discuss two problems I've encountered in the past weeks which gave me some (more) gray hair.

First thing happened this morning when a customer called saying that she couldn't run a report on an advanced find she had been using earlier. I tried to use the report on a small number of objects, 10 or so, on ALL objects and using the advanced find to select many objects (roughly 1700). I had no problems but when the customer did the same thing she got the following results: On a few objects the report worked as intended, on 250 objects it worked, on all objects it worked but when chosing all objects on all pages of the selected view after using the advanced find the report viewer just showed "error on page" at the bottom of the window. When closing the window I got prompted if I wanted to send info to Microsoft which I viewed and it said that "the object doesn't support the property or method".

Considering that I could use the report I set the system administrator role for the customer and when she tried again the report worked. A security issue one would think, well I removed the system administrator role to start test different possible scenarios but gave it a go again and tested the report. To my surprise it worked, the only thing I did was to assign the sysadmin role to the user, run the report and then remove it again. Very strange.

The other problem I had a few weeks ago when I was modifying existing, and working, code with a new function. Things went south pretty fast and I had to acquaint myself with the wonderful world of error messages in CRM 2011. What I did was that I needed to move variables from the pre operation state to the post operation state of a plugin. With these variables I would do an update and it had to be done after the operation.

Right, I consulted the all knowing SDK, The Junior Woodchuck Guidebook of Dynamics CRM. The answer was actually quite simple, SharedVariables. So since I wanted to pass a few variables I had a look at the structure which was a key-value pair so I figured I could pass an XML-object, which I did.

That was not the correct thing to do. There were no error messages when I did it but boy did things blow up when I used the plugin. It seems that you can't put anything serializable in the shared variables so I had to somehow enumerate the data that I put into the shared variables and then go through the set in the post state code, which worked quite alright actually. Lessen learned, don't put serializable objects in the shared variables, even if an XML might seem like something else.
In hindsight, I wonder if it might have worked with an XML as a string field which you read into an XML in the post state code.

Rickard Norström
Developer at CRM-Konsulterna
www.crmkonsulterna.se

Time zones in Dynamics CRM, well all of them

Ok, so you're booking meetings in Dynamics CRM and it's mostly fine and dandy. The meeting starts at one o'clock so you book it at one o'clock. But what happens when you know you have a meeting at one o'clock in Helsinki, or in Auckland?

This is where things get a bit interesting. What you can do is to go to you personal settings, change it to Auckland (GMT + 12), which you can see in the picture below.





















Now, click ok, and you can book you meeting at 1 PM, invite all people that are supposed to attent and save it. Then return to your own time zone, in my case GMT+1 for Stockholm and the meeting time jumps to 3 AM as seen in below picture.















Ok, so far, so good. But if you're in an international organization and you book a bucketload of meetings every day, doens't this mean there will be a LOT of clicking?
The short answer is, yes, there will be a lot of clicking. How much you might wonder.

I have actually done the math. Now, considering that you change the time zone of your personal settings for each meating you book you need 5 clicks to get to the desired time zone, then wait for the form to reload and you can enter the start time of the meeting, and then save. If you want to return to your own time zone after saving, it's another five clicks, since you might want to check when the heck the meeting will take place in some civilized time zone, even thought the start time will most likely be far from civilized.
Now wait, if you're booking a lot of meetings, you might have several meetings in the same time zone you might think, and you don't have to check your own time zone each time you book a meeting.

Fair enough, let's say you book 16 meetings a day in at least 4 different time zones, that will give you at least 25 bonus clicks which might not seem much but you also have 5 reloads of the form that make the application perhaps not seem like the most smooth tool in the box. The customer will most likely point out that you can have different time zones for start and end time if you make the booking in outlook, so why on earth isn't it possible to book a meeting in a different time zone in CRM?

One can only speculate on the reasons, it is for sure that the reason  isn't that the application is from USA since USA alone has a couple of time zones. I seriously have no good answer to this.

The reason why I'm writing about this is of course since I have run into this with one of our customers. So how can you solve this?

There must be a couple of solutions to this and I will show you our solution but first a bit of background.

- One, there is a timezone format of the whole number field. It's broken, don't use it. I tried to use it and as soon as I inserted data in the field I got an error. I started a thread on connect for this issue, so please vote on Connect if you have an account so that might get fixed.
- Two, event with that field functioning, it's no walk in the park to make the time zones work...
- Three, all datetimes are stored in the database in Zulu time, which is UTC, ie, no daylight saving whatsoever, which I will come back to later. This means that you will have to do something with that time if you're working with the start/stop time programatically.
-Four, did I mention daylight savings? Yes, that will make it trickier.
-Five, and this is someting I didn't think about but I discover it rather harshly, you computer and your CRM might very well be running on different time zones.
-Six, did anyone say daylight saving?

Solution idea:
Keep the start and end time fields, you will need those, and add extra fields for start and end time which will show the start and end time of the meeting where the meeting takes place.

Right, this can be done, but how do we know in which time zone the meeting takes place?

Add a time zone field.

Ok, so how do we keep these fields updated? Let's write som js to keep them updated, take the time from CRM, add or subtract the relevant time difference and everything's fine. Well not quite.

I will continue on the solution next time, which I promise won't be another six months.



 

Rickard Norström
Developer at CRM-Konsulterna
www.crmkonsulterna.se