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!
|
|
Group Creation from code
Posted: 25 Jun 10 8:40 AM
|
I am creating contact adhoc groups from code.
I have a couple of problems with the groups that I create from the code. I don't seem to be able to add new contacts to the group from the UI, when selecting the option the list of groups doesn't have my newly created one in it. It also requires a logout/login for me to see the newly created group. So it appears to be a refresh issue with the new groups created but I don't seem to be able to refresh the groups.
I'm trying the refreshing using: -------------------------------------------------- GroupContext groupContext = GroupContext.GetGroupContext(); groupContext.CurrentGroupID = id;
I'm creating the groups using the following ----------------------------------------------------- GroupTranslator.GroupTranslatorClass gt = new GroupTranslator.GroupTranslatorClass();
try { // We create the new group based on the layout latest contacts group. string templateGroupId = ConfigurationManager.AppSettings["TemplateGroupId"].ToString(); string xml = gt.GetBlankGroup("Contact", connection, templateGroupId);
System.Xml.XmlDocument document = new System.Xml.XmlDocument(); document.LoadXml(xml);
if (document.InnerText != null) { document.SelectSingleNode("//SLXGroup/adhocgroup").InnerText = "true"; document.SelectSingleNode("//SLXGroup/plugindata").Attributes["name"].Value = groupName; newGroupId = gt.SaveGroup(document.OuterXml, connection); } } catch (Exception ex) { string error = string.Format("There was an error creating the new group, please contact helpdesk: {0}", ex.Message); throw new Exception(error); }
|
|
|
|
Re: Group Creation from code
Posted: 28 Jun 10 8:58 AM
|
Having some success with "currentgroupid = " seems to work when using GroupContext.GetGroupContext().CurrentGroupInfo.ClearCache();
I have noticed that after a while you can add contacts to the groups, not sure what is refreshing this though (yet) |
|
|
|
Re: Group Creation from code
Posted: 28 Jun 10 10:54 AM
|
Regarding the Adhoc Group issue:
Are you setting the AdhocGroupID value? (Should be the Group ID, which will be stored also under the DATACODE column on the Plugin Table.
true p6UJ9A0005O4
|
|
|
|
Re: Group Creation from code
Posted: 28 Jun 10 10:58 AM
|
I've found a much better way of doing this:
I am now using this to create the new group and get an id. string newGroupId = Sage.SalesLogix.Client.GroupBuilder.GroupInfo.CreateAdHocGroup("", "Contact", _groupName);
I then insert all the values into the adhocgroup table using a stored procedure.
This refreshing the new group and allows additions of contacts. |
|
|
|
Re: Group Creation from code
Posted: 02 Jul 10 4:04 AM
|
A note for anyone else creating adhocgroups from code using the GroupInfo.CreateAdHocGroup() method;
You need a groupcontext for this to work otherwise you get and object cant be null error from the method call, you need to check for group context and if there is none then set one, I managed it like this:
GroupContext context = (HttpContext.Current != null) ? (HttpContext.Current.Session["GroupContext"] as GroupContext) : null; if (string.IsNullOrEmpty(context.CurrentGroupID)) { context.CurrentTable = "CONTACT"; } |
|
|
|
Re: Group Creation from code
Posted: 02 Jul 10 4:11 AM
|
A note for anyone else creating adhocgroups from code using the GroupInfo.CreateAdHocGroup() method;
You need a groupcontext for this to work otherwise you get and object cant be null error from the method call, you need to check for group context and if there is none then set one, I managed it like this:
GroupContext context = (HttpContext.Current != null) ? (HttpContext.Current.Session["GroupContext"] as GroupContext) : null; if (string.IsNullOrEmpty(context.CurrentGroupID)) { context.CurrentTable = "CONTACT"; } |
|
|
|