Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Super Contributor
Posts: 21
Registered: ‎12-08-2009

How To Get Current SalesLogix User?

I need to get the current user's User object. 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?

Bronze Super Contributor
Posts: 204
Registered: ‎03-10-2009

Re: How To Get Current SalesLogix User?

Copper Super Contributor
Posts: 21
Registered: ‎12-08-2009

Re: How To Get Current SalesLogix User?

Thanks for the quick reply..

 

Sage.SalesLogix.Security is not showing up in Intellisense. I imagine it's not a valid namespace.

 

If I add a reference to it (Sage.SalesLogix.Security.dll), I get into a cascading effect of needing to add multiple other references. Does that seem right?

 

Thanks.

Bronze Super Contributor
Posts: 204
Registered: ‎03-10-2009

Re: How To Get Current SalesLogix User?

Sorry I got side tracked. Ok so where are you trying to add this code? Is it in a business rule? This is pretty standard code and works just about anywhere. I have personally used it tons of times so don't fret we will get it working Smiley Happy I just need a little more info on what you are trying to do and where in the product you are trying to do it.

Sr. Sales Engineer
Gene Arnold
Silver Contributor
Posts: 835
Registered: ‎03-24-2009

Re: How To Get Current SalesLogix User?

<rant>

This is just another example of not enough design being replaced by way too much C# .net code.......why don't we simply write this out in Assembly language and be done with it?

 

Could someone please explain to me why SLX couldn't have a simple statement like the following:

 

      string MyCurrentUserID = Sage.SalesLogix.GetInfo.CurrentUserID;

 

As a developer, I don't wan't tohave to worry about boxing, nulls, structs, inheritance, etc. just to cough up the logged in user's char 12 USERID. You can have all the happy code layers, methods, interfaces, classes, Lists, running behind the scenes to your non 4GL, non Visual coding content .....

 

Now that we have the userId, I need to see if they're in a Team.....

 

Sometimes less is more.......

</rant>

 

 

 

RJ Samp
Copper Super Contributor
Posts: 99
Registered: ‎07-04-2009

Re: How To Get Current SalesLogix User?

You mean like

 

BusinessRuleHelper.GetCurrentUser().Id.ToString();

 

Enjoy

 

Chris


Cheers
Chris Grant
Plus Consulting
Bronze Super Contributor
Posts: 192
Registered: ‎07-17-2011

Re: How To Get Current SalesLogix User?

When I attempt to add Sage.SalesLogix.BusinessRules.dll in the AssemblyReference Collection Editor I get an error:

 

Could not load exported type data for assembly 'Sage.SalesLogix.BusinessRules, Version=7.5.4.7097, Culture=neutral, PublicKeyToken=null' and type 'Sage.SalesLogix.Account.Rules'. (ActiproSoftware.SyntaxEditor.Addons.DotNet.Net20)

 

Could not load file or assembly 'Sage.SalesLogix.Services.PotentialMatch, Version=7.5.4.7097, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. (mscorlib)

 

Am I missing dll's?

Silver Contributor
Posts: 835
Registered: ‎03-24-2009

Re: How To Get Current SalesLogix User?


@ChrisGrant wrote:

You mean like

 

BusinessRuleHelper.GetCurrentUser().Id.ToString();

 

Enjoy

 

Chris


That gives me an error in 7.5.4 Web C# Code Snippet action Chris.

 

This is a winner:

string strCurrentUserID = Sage.SalesLogix.API.MySlx.Security.CurrentSalesLog ixUser.Id.ToString();

 

But still WAY too many keystrokes.

 

This would be WAY better:

string strCurrentUserID = SLX.CurrentUserId;

and all of the other happy horse stuff ( Sage.SalesLogix.API.MySlx.Security.CurrentSalesLog ixUser.Id.ToString()Smiley Wink could be handled any way you'd all like, including Assembler language for all I care (although APL was always a favorite).

 

What makes this worse is that you have to code the same functionality two different ways depending on if you are in a NON-OBSOLETE C# Code Snippet or a C# Code Snippet.....what a pain.

 

 

RJ Samp
Copper Super Contributor
Posts: 99
Registered: ‎07-04-2009

Re: How To Get Current SalesLogix User?

To be more specific then.

 

string strCurrentUserID = Sage.SalesLogix.BusinessRules.BusinessRuleHelper.GetCurrentUser().Id.ToString();

 

As I had Sage.SalesLogix.BusinessRules as a using.

 

Mind you if you set your using up as an alias you could get what you want.

i.e.

 

using SLX = Sage.SalesLogix.BusinessRules.BusinessRuleHelper;

 

This means you could then use

 

string strCurrentUserID = SLX.GetCurrentUser().Id.ToString();

 

 

 

Enjoy


Cheers
Chris Grant
Plus Consulting
Bronze Super Contributor
Posts: 192
Registered: ‎07-17-2011

Re: How To Get Current SalesLogix User?

This is nice, but does not work in mobile/sdata

 

string strCurrentUserID = Sage.SalesLogix.API.MySlx.Security.CurrentSalesLog ixUser.Id.ToString();

 

Attempting to go the BusinessRules route

 

				TITLE: 
------------------------------

An application exception has occurred.

------------------------------
ADDITIONAL INFORMATION:

Could not load exported type data for assembly 'Sage.SalesLogix.BusinessRules, Version=7.5.4.7106, Culture=neutral, PublicKeyToken=null' and type 'Sage.SalesLogix.Account.Rules'. (ActiproSoftware.SyntaxEditor.Addons.DotNet.Net20)

------------------------------

Could not load file or assembly 'Sage.SalesLogix.Services.PotentialMatch, Version=7.5.4.7106, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. (mscorlib)

------------------------------
BUTTONS:

OK

 What works in Mobile/Sdata?  I'm with RJ on this one, we should not have to be trying so hard just to get the current userid.

 

Thanks!

Norman