May be you remember, but not too long ago, I wrote a small piece of functionality to select a role when logging in
on a NAV 2009 RTC. You can read the article here. And here is the picture:
I got some remarks about the fact that it didn't work 100%. Now, I must say, I was doubting to go into it, because I noticed that it hadn't been downloaded too much so I figured: "waldo, you built something unuseful, dude.. .". But on the other hand, some people are using it .. so I did try to find out what went wrong.
Now, the thing that really got my attention was the fact that using this, it wasn't possible anymore to save views or Add Actions on Role Center with the "Add Action to Role center" Action (say that 10 times fast in a row ... :-) ) (thanks Steve and Willy to get this to my attention ..). If that was the case, then other personalisation-stuff might not work either. That would make this tool useless, I agree .. .
It was strange, though, what could I have done wrong? I just manipulated that one trigger in CodeUnit 1: "DefaultRoleCenter". So I figured, OK, if I'm not able to save views with the rolecenter that I come up with, then probably I'm not able to save views with the default code: the default rolecenter 9006, that is returned in a trigger in codeunit 9170 "Conf./Personalization Mgt.". So I tested in a default database .. and all works just fine... . Strange.
The only difference was that in the default database, the trigger looked like this:
DefaultRoleCenter() : IntegerEXIT(ConfPersMgt.DefaultRoleCenterID); //Removed..
And in my trigger, it looked like this:
DefaultRoleCenter() : Integer//*** WALDO >>IF NOT MySessionMgt.CurrentProfileSelected THEN BEGINMySessionMgt.SetCurrentProfile(UserProfileMgt.SelectRoleCenter);EXIT(MySessionMgt.GetCurrentRoleCenterID);END;//EXIT(ConfPersMgt.DefaultRoleCenterID); //Removed..//*** WALDO <<
So the only difference that I saw was: that I used slightly more code then the default one.. . Because of the fact that codeunit 1 just isn't that "logical" and doesn't always react like any other part of the application .. what if I removed the "IF" and went back to the original: one-liner in that trigger. I restructured the code somewhat, and this was the result in CU1:
DefaultRoleCenter() : Integer//*** WALDO >>EXIT(MySessionMgt.GetCurrentRoleCenterID);//EXIT(ConfPersMgt.DefaultRoleCenterID); //Removed..//*** WALDO <<
Guess what .. all worked fine now (at least for the "save views" part).. . Weird, huh? :-/
Anyway, you can download the new version here.
Well, I must have been a combination of both .. . The trigger is called twice. At least once I returned a value .. but the second time, I didn't. And probably that was the problem.
But then again .. it shouldn't call this trigger wice ;°).