back to top

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("type","G")
                     .SetAnsiString("teamname", TeamName)
                     .SetAnsiString("accessid", user.Id.ToString())
                     .UniqueResult());
        }
        
        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!

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Jason Buss
Jason Buss
Jason is a senior application developer with Customer FX.

2 COMMENTS

  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 rules.events.OnBeforeUpdate. 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.

      Ryan

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos