Passing Values Between Forms in Infor CRM (Saleslogix) Web

There are a few different ways to pass values or objects between forms in the Infor CRM (Saleslogix) Web client. Since Infor CRM is an ASP.NET application, you have all the things available in ASP.NET for persisting values such as the Session (See Kris Halsrud’s article on using the Session in Infor CRM). There is also a built in way to persist values as well using the State collection, which is available from the PageWorkItem.

Using the Page State Collection

The State collection works in a similar way to the ASP.NET Session (see differences at end of this article). Using it is identical to how to use the session. Here’s a sample:

// add myvalue
this.PageWorkItem.State["MySavedValue"] = myvalue;

// then later to retrieve
string myvalue = this.PageWorkItem.State["MySavedValue"].ToString();

// to remove

You can also use it to pass objects and Infor CRM entities around as well. Let’s say you have a form where you want to allow the user to select products to add to something, but you don’t want to save them right away until the user does some action. You can persist the selected products in the page state until you’re ready to save them. Something like this:

var prod = this.BindingSource.Current as Sage.Entity.Interfaces.IProduct;
//prod is my already populated object that was bound to a form in a dialog.
//instead of calling it's Save method, will store it in the State to call this later.
List<Sage.Entity.Interfaces.IProduct> list;

// first check the page state to see if you have the collection of products saved
// if it doesn't exist, create an empty list, otherwise get the collection from 
// the page state and add the product to it 
if (this.PageWorkItem.State["ProductsList"] == null)
    list = new List<Sage.Entity.Interfaces.IProduct>();
    list = (List<Sage.Entity.Interfaces.IProduct>)this.PageWorkItem.State["ProductsList"];

Now, later when you want to actually save these products you could do this:

var myEntity = this.BindingSource.Current as Sage.Entity.Interfaces.IMyEntity;
List<Sage.Entity.Interfaces.IProduct> list;

// get the list of products from the page state
if (this.PageWorkItem.State["ProductsList"] != null)
    list = (List<Sage.Entity.Interfaces.IProduct>this.PageWorkItem.State["ProductsList"];
if (list != null)
    foreach (Sage.Entity.Interfaces.IProduct prod in list)
        // add to the entity (or whatever you need to do with them)
        // etc


Of course, that is just an example, but I wanted to point out how easy it is to pass objects around using the page state.

One more note, if you don’t have a built-in PageWorkItem in wherever you’re using this code, you can get it via the locator service. Note: PageWorkItem is already built-in to all quickforms and any SmartParts that inherit from EntityBoundSmartPart.

IPageWorkItemLocator locatorService = Sage.Platform.Application.ApplicationContext.Current.Services.Get<IPageWorkItemLocator>();

Differences Between Using Session and Page State

There are some differences between using the ASP.NET Session and the built-in Page State collection. One way is not right and the other wrong; instead, it depends on how you need to use it. Each have different purposes.

The ASP.NET Session object is maintained for each user that requests a page or document from the Infor CRM ASP.NET application. Variables stored in the Session object are not discarded when the user moves from page to page in the application; instead, these variables persist as long as the user is accessing pages in your application. So, to be clear, when you set something in the Session, it stays there until the user logs out our closes the browser (or something else happens to cause the session to clear or renew). This means, if you put something in the session on PageA, then the user leaves this page and does other stuff and later returns to PageA, whatever you put into the session will still be there. You might not want this behavior. Instead, it sometimes makes sense to start fresh when the user comes to PageA and not have whatever was saved in the session from their last visit to PageA.

The built-in Page State works in the same way as the ASP.NET session, except it only persists as long as the user is on that page. So, if the user visits PageA and you put something into the page state, then they leave and do other things and later return to PageA, you’re starting fresh, without the value you put into the state the last time. One thing to keep in mind, dialogs are a part of the page. So, if you put something in the page state in a dialog, that will be available on other forms on that page. So any SmartPart or QuickForm added to the page can access values stored in the state for that page.


Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

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!