Using Global Script functions in InforCRM

I recently had a project that required me to be able to check if a user belonged to a particular team.  A previous post by Ryan showed me how to query team membership, but rather than setting this up as a Business Rule, I wanted to create it as a Global function that could be called from anywhere without having to worry about instantiating an entity to access the business rule.

Instead of creating a business rule, I created a Global CS script to contain my function, which I could then use from anywhere. My script contains the following code:

using System;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using Dropthings.Web.Util;
using Sage.Integration.Messaging;
using Sage.Platform.Application;
using Sage.Platform.Application.Diagnostics;
using Sage.Platform.Application.UI.Web;
using Sage.Platform.Diagnostics;
using Sage.Platform.Utility;
using Sage.SalesLogix;
using log4net;
using log4net.Config;
public class FXGlobal : HttpApplication
    public static Boolean IsUserOnTeam(String TeamName)
        bool OnTeam = false;
        var user = Sage.SalesLogix.API.MySlx.Security.CurrentSalesLogixUser;
        using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper())
            OnTeam = 0 < Convert.ToInt32(session.CreateQuery("select count(*) from OwnerRights r where r.Owner.Type = :type and r.Owner.OwnerDescription = :teamname and r.User.Id = :accessid")
                     .SetAnsiString("teamname", TeamName)
                     .SetAnsiString("accessid", user.Id.ToString())
        if (user.Id.ToString().Trim().ToUpper() == "ADMIN")
            OnTeam = true;
        return OnTeam;

The using statements on the script I copied from the Existing Global.cs script.  Some of them are probably not needed for what I am doing, but it was easier to add them all in rather than taking the time to figure out what each assembly does.  You’ll note also, that the function is contained in a new Public class, which inherits from HttpApplication.

Once I created the script, called FXGlobal.cs, we have to add it to InforCRM.   The place we need to do this is in the App_Code folder under support files in the Portal Manager. (Portal Manager->Saleslogix Client->Support Files->App_Code.)  From that location, right-click the App_Code folder and select “Add Existing”.  Browse to the new CS file, and that should be it!  The script has now been added to InfoCRM.

To use this function in a code Snippet action item, for example; we just need to reference the Class Name and then the function.  From my example, this would be FXGlobal.IsUserOnTeam(“TeamName”).

That’s all there is to it!   All in all, a very simple way to create functions that are accessable throughout InforCRM.

Thanks for reading!


Jason Buss

Jason is a senior application developer with Customer FX.


  1. I am wondering if this same methodology makes the custom script available in an entity’s business rules. I have tried putting function into a custom .cs, adding that custom .cs to App_Code, then calling function from an entity’s It does not appear that the business rule events have access to the .cs function. Can you clarify?

    • Richard,

      Code placed in the App_Code folder is not accessible to code in a DLL, which is where business rules live. If you need it to be accessible in the business rules as well, it’s better to put the code in a compiled DLL and place it in the bin.


Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!