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!
|
|
Disable chexkbox for specific users
Posted: 29 Apr 10 5:31 AM
|
Hi All,
I have a checkbox on a form that i only want certain users to be able to check.
Im trying to create a C# snippet to do the job at the moment but im having some trouble.
Could anyone help or point me in the right direction please. Working on it myself ive come to the following code to find out the current logged on user but it returns errors.
Sage.Platform.Security.UserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get(userService) as Sage.Platform.Security.UserService; IUser user = userService.GetUser(); |
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 6:06 AM
|
I have also tried this:
Sage.Platform.Security.IUserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get(); string user = userService.UserName;
which gives me the error:
The type arguments for method 'Sage.Platform.Application.ServiceCollection.Get()' cannot be inferred from the usage. Try specifying the type arguments explicitly.
|
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 6:09 AM
|
Hi Andrew
I have used the following:
SLXUserService service = ApplicationContext.Current.Services.Get() as SLXUserService; User currentUser = service.GetUser();
You can then access the current user.
I have also used the following to get a list of teams that the user is in. IList teamlist = Sage.SalesLogix.Security.Owner.GetTeamsByUser((Sage.SalesLogix.Security.User)currentUser );
|
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 6:15 AM
|
Thanks for your reply. This is similar to one of my early trys but i get the error:
The type or namespace name 'Security' does not exist in the namespace 'Sage.SalesLogix'
when i look at my line "using Sage.SalesLogix......." the only option that follows the "." is API.i also get:
The type or namespace name 'SLXUserService' could not be found
and the original:
The type arguments for method 'Sage.Platform.Application.ServiceCollection.Get()' |
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 7:30 AM
|
I believe you can do it this way too.
IUserService us = ApplicationContext.Current.Services.Get(); IUser user = EntityFactory.GetById(us.UserId); |
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 7:36 AM
|
Thanks for your reply again Tony i really appreciate your time.
Unfortunately i still get the error:
The type arguments for method 'Sage.Platform.Application.ServiceCollection.Get()' cannot be inferred from the usage
along with:
The name 'EntityFactory' does not exist in the current context |
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 7:46 AM
|
You need to use: Sage.Platform.Application.ApplicationContext.Current.Services.Get();
Not, Sage.Platform.Application.ServiceCollection.Get();
Make sure you fully qualify or add using statements:
eg Sage.Platform.EntityFactory or add Using Sage.Platform;
|
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 8:01 AM
|
That is the line i use but i get the same error
also any tutorial, help file or example of this sort of thing i can find uses:
Sage.SalesLogix.Security.SLXUserService..... but i cant add Sage.SalesLogix.Security as a using.
The only choice i get is Sage.SalesLogix.API Am i missing something?????? |
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 8:05 AM
|
sorry was doing it from memory, you need to specify the service that you are getting.
Sage.Platform.Application.ApplicationContext.Current.Services.Get(); |
|
|
|
Re: Disable chexkbox for specific users
Posted: 29 Apr 10 9:32 AM
|
Finally it works!!! Next part (sigh) is how i control the Enabled property of the check box on the form through my code snippet? SO now i have the code to get the currently logged on user, If the user is not "user1" then disable the check box.
Let the confusion begin (i miss 7.2 ) |
|
|
| |
|