Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, August 18, 2025 
 
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!
 Web Forums - SalesLogix Web Platform & Application Architect
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.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Problem with Business Rules
Ken Poggensee
Posts: 71
 
Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jun 08 3:17 PM
Ok.. I was thinking this was going to be easy, but…

I have a 1:M off Accounts called QuoteHeader. It also has a 1:M for QuoteLines (irrelevant at this point really). The QuoteHeader is set up as a main view so when you look at the grid and select an record it takes you to the main view.

So here is what I am looking to do. I want a tab view with a datagrid on it for the QuoteHeader main view that will show all the Contacts for associated Account.

So I tried using the for the GetByMethod of the datasource and what not and could not get it to work. My next thought was to create a business rule that would just return a collection of the Contacts that I was looking for.

This is where I need your help. I am getting the following error:
----------------------------------------------------
Line 53: void dsAccounts_OnCurrentEntitySet(object sender, EventArgs e)
Line 54: {
Line 55: dsAccounts.SourceObject = BindingSource.Current;
Line 56: RegisterBindingsWithClient(dsAccounts);
Line 57: }
----------------------------------------------------
DynamicMethodException: Unable to locate type information 'Sage.BusinessRules.CodeSnippets.QuoteHeaderBusinessRules, Sage.SnippetLibrary.CSharp' for business rule 'QuoteHeader.GetQuoteContacts']
Sage.Platform.DynamicMethod.BusinessRuleMethod.GetPrimaryParameters() +105
----------------------------------------------------


Here is the code in my Business Rule.
----------------------------------------------------
#region Usings
using System;
using Sage.Entity.Interfaces;
using Sage.Platform;
using Sage.Platform.Repository;
#endregion Usings

namespace Sage.BusinessRules.CodeSnippets
{
public static partial class QuoteHeaderBusinessRules
{
public static void GetQuoteContacts( IQuoteHeader quoteheader, out object result)
{
Sage.Platform.Repository.IRepository contact = EntityFactory.GetRepository();
IQueryabe qry = (IQueryable)contact;
IExpressionFactory ef = qry.GetExpressionFactory();
ICriteria criteria = qry.CreateCriteria();
criteria.Add(ef.Eq("Account", quoteheader.Account));
result = criteria.List();
}
}
}
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Jun 08 7:25 AM
Ken, use Reflector ( http://www.aisto.com/roeder/dotnet/ ) to inspect Sage.Entity.Interfaces, Sage.SalesLogix.Entities and Sage.SnippetLibrary to ensure that your does indeed exist. I assume you rebuilt interfaces before a deploy. I find it interesting that your result is of type object and not IList. Aslo looking at your query there getting of the repositiory needs to identify the type of entity it should return. Right now how would it know that it should be returning a list of contacts.

Your code has some spelling errors as well. I suspect that it was not compiling and that is why the rule did not exist.

IRepository repos = EntityFactory.GetRepository<IContact>();
IQueryable query = repos as IQueryable;
IExpressionFactory ef = query.GetExpressionFactory();
ICriteria criteria = query.CreateCriteria();
criteria.Add(ef.Eq("Account", quoteHeader.Account));
result = criteria.List();

I was never a fan of the query expression stuff, way too many lines of code and the intent is really hard to read (for me anyways ) So you might also try something like;

using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper())
{
string hql = string.Format("Select c from Contact c where c.AccountId = '{0}'", quoteHeader.Account.Id);
NHibernate.IQuery query = session.CreateQuery(hql);
return query.List<IContact>();
}

- Mark
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Jun 08 12:12 AM
Couldn't you just solve this by using quoteHeader.Account.Contacts as your data source? Did you try just typing that in for the data source (it won't appear in the drop down to select for the data source, but it might let you just type it in manually).

-Ryan
[Reply][Quote]
Ken Poggensee
Posts: 71
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Jul 08 5:07 PM
I am trying to use Marks example above using the NHibernate in a business rule for another module I am doing and getting error:

"The type or namespace name 'ISession' could not be found (are you missing a using directive or an assembly reference?)"

I tried adding a "using NHibernate;" in my using region thinking it might work, but got the same error

Long story short, I have a pretty deep SQL statement that I need to return a list of particular records and bind it to a datagrid. Right now I am just trying to get a working example of something simple. My code is below...

----------------------------
#region Usings
using System;
using Sage.Entity.Interfaces;
using Sage.Platform;
using Sage.Platform.Repository;
using NHibernate;
#endregion Usings

namespace Sage.BusinessRules.CodeSnippets
{
public static partial class AccountBusinessRules
{
public static void GetMyAuthorization( IAccount account, out IList result)
{
using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper())
{
//for the time being just return ALL the VICAuthorizations for this account (refine SQL later)
string hql = string.Format("Select v.* from VICAuthorization v where v.AccountId = '{0}'", account.Id);
NHibernate.IQuery query = session.CreateQuery(hql);
return query.List();
}
}
}
}
-----------------------------------


Thanks in advance for insight any1 can provide.

-Ken-
[Reply][Quote]
Andy Norris
Posts: 39
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jul 08 4:33 PM
Ken - Just a thought, but I had a similar issue to your "type or namespace could not be found" one. It turned out to be MUCH simpler in my case to just write a custom DLL and reference that instead of writing a code snippet. If you have Visual Studio, I would suggest creating a class project referencing the needed Saleslogix DLLs and then write a custom method. I have lobbied for keeping as much of our code as possible in a custom assembly instead of using code snippets, partly because of the bad housekeeping the App Architect does for old/deleted code snippets and partly for ease of reference.
[Reply][Quote]
virtam
Posts: 43
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Jul 08 6:21 PM
Andy,

In the lines above maybe you can find the answer for this issue. This is peace of FAQ delivered by SAGE, if you want to get all other questions contained in the FAQ documment please inform your email address and then I can send you the complete information for your reference.

Good luck.

Why do I get build errors when attempting to implement some of the examples in this FAQ?

Sage SalesLogix uses code generation to convert business rule code snippets into binary assemblies for use in the web client. In order to build snippet libraries, the .NET compiler needs to be able to find any assemblies referenced in snippet code. If it can’t find a referenced assembly, you’ll get an error like this:

ERROR - %path%\codesnippet.cs(33,18): The type or namespace name 'SalesLogix' does not exist in the namespace 'Sage' (are you missing an assembly reference?)

The Application Architect uses an XML configuration file to track assembly references:

C:\Documents and Settings\All Users\Application Data\Sage\Platform\Configuration\Global\codesnippets.xml

The “defaultReferences” section contains the assembly reference list. Out of the box, the list includes Sage.Platform, Sage.Platform.Application, Microsoft.Practices.ObjectBuilder, Sage.Platform.Configuration, and Sage.Entity.Interfaces. If you reference any other assemblies, you’ll need to add entries for those in the defaultReferences section. You’ll see by the namespace prefixes that some of the examples in this FAQ reference assemblies not in this list.

Note: A future release of the Sage SalesLogix Application Architect will include UI for managing assembly references in your application, so modification of codesnippets.dll should just be considered a temporary workaround. Also, codesnippets.xml is generated automatically if it doesn’t exist, so you can delete the file to return to the original configuration.

Another error you might encounter in the gold release of SalesLogix 7.2 is related to doing a “full” build of the web platform (holding down the key while clicking “Build Web Platform”:

ERROR - %path%\codesnippet.cs(29,41):The type or namespace name 'I' could not be found (are you missing a using directive or an assembly reference?)

In this case, would be the name of a custom entity you have created and are referencing in a code snippet. This is a defect in the gold release where a full build uses the Sage.Entity.Interfaces.dll that is installed with the product, rather than the modified version of that assembly (which includes your customizations) in the output directory. We’ve fixed this issue for the Service Pack 1 release. In the mean time, you can work around the problem by either doing a regular build (not holding down the key), or just building the code snippets, after you get the above error.
[Reply][Quote]
Andy Norris
Posts: 39
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Jul 08 8:23 AM
virtam - I messaged you my email address. I look forward to reading the documentation. I've just reviewed Ryan's latest blog post with the 7.5 screenshots, and I'm looking forward to seeing what improvements they've made to the App Architect. Hopefully, they'll release on schedule.....
[Reply][Quote]
NixDev
Posts: 98
 
Re: Problem with Business RulesYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Apr 09 7:31 PM
Virtam, I also sent you my email. Could you send me the faq?
THANKS!
[Reply][Quote]
 Page 1 of 1 
  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!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/18/2025 3:56:08 AM