Showing results for 
Search instead for 
Do you mean 

Another way to use SalesLogix Roles

by garnold on ‎08-30-2011 08:01 AM

I was asked to build a feature into a proof of concept that would alert people when a field was set to a certain value. This is not hard at all with SalesLogix, but I wanted to do this in a way that the admin could add or remove people easily from the notification list. Hard coding user names into the action is really not a great way to go so SalesLogix Roles came to mind.


The idea was to add users to a specific role and each user would have an activity created on their calendar if a specific field was changed and it's value was equal to a predifined value.


To prove this out I chose the status field against the account entity. When the status field gets changed to purge all users that are part of the "Alert/Account/Status" role would get an activity placed on their calendar alerting them of this change. The notification could certainly be just about anything, but this was the easiest thing to whip up and demo.


Below you will find the code that I attached to the "On After Change" event for the status property.



if(args.NewValue != null)
				string newValue;
				newValue = (string)args.NewValue;
				if(newValue == "Purge")
					Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IRole> rep = Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.IRole>();
					Sage.Platform.Repository.ICriteria criteria = rep.CreateCriteria();
					System.Collections.IList results = criteria.List();
					if (results.Count > 0)
						Sage.Entity.Interfaces.IRole role = (Sage.Entity.Interfaces.IRole)results[0];
						foreach (Sage.Entity.Interfaces.IUserRole user in role.Users)
							string name = user.User.UserName;
							Sage.Entity.Interfaces.IActivity newActivity = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IActivity>();
							newActivity.AccountId = account.Id.ToString();
							newActivity.Description = "Account set to purge";
							newActivity.Category = "Alert";
							newActivity.Notes = account.AccountName + " has just been set to purge";
							newActivity.UserId = user.User.Id.ToString();


Register Read Guidelines Request Partner or Employee Access

What's New in 8.1