7/6/2025 8:29:20 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
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!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
7.5.1 "Common" code
Posted: 23 Jun 09 8:31 AM
|
7.5.1: I want to create some code that I can call from C# snippets (I want to call the code in multiple forms) that will return whether the current user is on a specific team or not. I created an external assembly (code below) and added it to the support files. When I try to add the code as a Business Rule to the User or UserInfo tables, I get an error that the "IsOnTeam" does not have an implementation. How do I go about doing this?
public static void IsOnTeam(String TeamID, out bool result) { bool Result = false; Sage.Platform.Security.IUserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string strUserID = userService.UserId;
Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get(); //Read Data using (IDbConnection conn = service.GetConnection()) { conn.Open(); using (IDbCommand command = conn.CreateCommand()) { command.CommandText = string.Format("SELECT SECCODE.SECCODEDESC FROM (SECCODE INNER JOIN SECCODEJOINS ON SECCODE.SECCODEID = SECCODEJOINS.PARENTSECCODEID) INNER JOIN USERSECURITY ON SECCODEJOINS.CHILDSECCODEID = USERSECURITY.DEFAULTSECCODEID WHERE SECCODE.SECCODEID='{0}' AND USERSECURITY.USERID = '{1}'", TeamID, strUserID); if (command.ToString() != "") { Result = true; } else { Result = false; } } } if (strUserID == "ADMIN") Result = true; result = Result; // return Result; } |
|
|
|
Re: 7.5.1 "Common" code
Posted: 23 Jun 09 3:41 PM
|
AFAICT, there is no way to add a business rule to the User entity.
This is because the actual implementation of the security related entities is on a separate assembly (it's not in Sage.SalesLogix.Entities.dll).
So, you can tell SalesLogix that you want to add a business rule, that gets added to the interface, but you can't insert the actual rule.
A workaround is to add the business rule into the entity you're going to bound the forms in which you want to use the method (e.g. account).
It's dirty and not exactly good practice, but it works.
Another possibility, maybe cleaner, maybe not, is to inject a class into the SnippetLibrary.
How do you do this?
In the code snippet of the business rule insert something like:
namespace MyNamespace {
public static class MyHelperMethods {
public static void IsOnTeam(String TeamID, out bool result) { ... }
}
}
}
And then call it from wherever you want. Obviously, it doesn't matter really where you're going to put this code. Every code snippet for a business rule will be compiled into the SnippetLibrary dll.
Hope it helps.
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|