7/5/2025 6:30:00 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.
|
|
|
|
Setting Control properties from a business rule
Posted: 04 Aug 09 12:35 PM
|
Hi All,
I'm having trouble implementing a business rule, setting a control property based on team membership. I'm hoping that someone can tell me if I'm going down the right path with how I'm trying to do this, and if so, to shed some light on an error I'm receiving.
The field is a picklist on the AccountDetail form. I created a business rule under account with the followng code:
namespace Sage.BusinessRules.CodeSnippets { public static partial class AccountBusinessRules { public static void CanEditDealerPriorityStep1(IAccount account) { // TODO: Complete business rule implementation Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get(); Sage.Entity.Interfaces.IUser user = usersvc.GetUser();
if (IsUserOnTeam(user, "test")) { IAccountDetails.AccountType = true; } else { IAccountDetails.AccountType = false; } }
private bool IsUserOnTeam(Sage.Entity.Interfaces.IUser user, string team) { using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper()) { return 0 < Convert.ToInt32(session.CreateQuery("select count(*) from OwnerRights r where r.Owner.OwnerTypeChar = :type and r.Owner.OwnerDescription = :teamname and r.User.Id = :accessid").SetAnsiString("type", Sage.SalesLogix.Security.StringEnum.GetStringValue(Sage.SalesLogix.Security.OwnerType.Team)).SetAnsiString("teamname", team).SetAnsiString("accessid", user.Id.ToString()).UniqueResult()); } } } }
I added this business rule to the LoadAction items on the accountdetail form, but I get the following exception: Exception information: Exception type: DynamicMethodException Exception message: Unable to locate type information 'Sage.BusinessRules.CodeSnippets.AccountBusinessRules, Sage.SnippetLibrary.CSharp' for business rule 'Account.CanEditAccountType'
I should add, I'm useing the code that Ryan provided in his blog to determine team membership:
http://customerfx.com/pages/crmdeveloper/2009/02/04/determining-if-a-user-is-a-member-of-a-team-in-saleslogix-web.aspx
Am I barking up the wrong tree here? If not, I'm sure I'm missing something basic...
Any ideas?
Thanks |
|
|
|
Re: Setting Control properties from a business rule
Posted: 05 Aug 09 2:56 AM
|
Hi,
You can not modify controls from a business rule. The business rule is just logic, it is not for modifying any controls. What you can do is return a value from the rule, which you use in the load action to modify the control. So if you e.g. return True, then you can do something like if (account.myrule) pklAccountType.Enabled = Fales;
This would work.
Thanks! Alexander |
|
|
|
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!
|
|
|
|
|
|
|
|