The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
How To Get The Current SalesLogix User
Posted: 28 Jun 10 3:51 PM
|
I need to get the current user's User object. I've been reading all the threads I can find on this. Seems like I've almost got it. I don't understand why this is so hard.
I am using this code: SLXUserService service = ApplicationContext.Current.Services.Get() as SLXUserService; User currentUser = service.GetUser();
But I keep getting consecutive error messages about adding 2 or 3 new references. What all references are required? Security? Entities? Sage.SalesLogix? ugh.
I've also tried using the API namespace. That current user it returns cannot be converted into a normal IUser.
Is there a better/easier way that I am missing?
|
|
|
|
Re: How To Get The Current SalesLogix User
Posted: 28 Jun 10 4:27 PM
|
Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser returns a Sage.SalesLogix.Security.User object. Not sure why you wouldn't be able to cast that back to the Interface. |
|
|
|
Re: How To Get The Current SalesLogix User
Posted: 28 Jun 10 4:43 PM
|
That's weird. In my specific case I have a UserControl called CheckedBy. When I try to use this code:
opp.MeasurementServices.CheckedBy = (Sage.Entity.Interfaces.IUser) Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser;
I get these two errors:
1. The type 'Sage.SalesLogix.Security.User' is defined in an assembly that is not referenced. You must add a reference to assembly 'Sage.SalesLogix.Security...
2. Cannot convert type 'Sage.SalesLogix.Security.User' to 'Sage.Entity.Interfaces.IUser'
What am I missing? |
|
|
|
Re: How To Get The Current SalesLogix User
Posted: 28 Jun 10 5:09 PM
|
Obviously you are missing a reference to the Sage.SalesLogix.Security.dll.
Error #2 is just a cascading error. Once you add a Reference to that DLL it will go away as well, since Sage.SalesLogix.Security.User is derived from Sage.Entity.Interfaces.IUser.
Also, keep in mind that IUser is just an interface. In this case, you are actually going to be working with a User object regardless of the fact that you are casting it to the Interface.
Now, how to add the Reference from the App Architect: - While editing your Code Snippet, make sure that the Properties tab is visible. - From the Properties tab, click on the Elipsis next to AssemblyReferences - On the Dialog that Opens, click on the Add button, then set the Assembly path to "Sage.SalesLogix.Security.dll" (I believe you could leave the Hint Path blank) for this dll.
Go ahead and rebuild and retest.
|
|
|
|