Limiting a Product lookup to current Account Product records in Infor CRM (Formerly Saleslogix)

I recently worked on a project which contained a Product Lookup control on an Account-level tab.  In this case, the lookup is only supposed to return products that are also AccountProducts for the current Account.  To do this, you can set the Lookup control to pull from the AccountProduct entity, then use code to save the Product from that entity and save it to your custom entity.

In your lookup control:

Set the Lookup Binding Mode to “Object”, and set the Lookup Entity Name property to “AccountProduct”.  Also, set the SeedProperty property to be “Account.Id”. You will have to type in that value.  Do not set the Data Bindings property on the lookup control.  Since the lookup will return an AccountProduct entity record, we need to handle everything via code.

On the OnChange action of the Lookup Control, create a new C# Snippet Action item.  The code reads as follows:

Sage.Entity.Interfaces.IAccountProduct AP = lkeProductLookup.LookupResultValue as Sage.Entity.Interfaces.IAccountProduct;
if (AP != null)
    Sage.Entity.Interfaces.INewTable new = this.BindingSource.Current as Sage.Entity.Interfaces.INewTable;
    new.Product = AP.Product;


In this code, we are creating an AccountProduct object (AP), and then we create an object for the current entity called “NewTable” (new).  Once we have both entity objects, we simply set the Product entity property with the AccountProduct entity property, and we are good to go.


Now that we’re saving the correct Product, we need to add additional code to the form in order to set the seed property of the lookup control.  If we don’t do this, the lookup will return all AccountProduct records instead of just the current Account’s AccountProduct records.  We’re also using the GetParentEntity function to return an Account Entity object for the record we are currently working with.

Sage.Entity.Interfaces.IAccount acc = this.GetParentEntity() as Sage.Entity.Interfaces.IAccount;

if (acc != null) {
    lkeProductLookup.SeedValue = acc.Id.ToString();    


This sets the SeedValue to the current AccountID, restricting the lookup to this Account’s product records.  We already set the SeedProperty property, and this code sets the SeedValue property.


One final item…  Since the Lookup control is unbound, we would normally need to add some code on the Load action of the form, to show the records product value in the product control.  When working on this, I found that you couldn’t set the Lookup control’s LookupResult property.  Even if setting that property, the value wouldn’t display.  In order to get around this, I changed the Lookup Display Mode to be “Button Only”, and I added that control, along with a bound text box control to a control container.  The text box has it’s DataBindings set to NewTable.Product.Name, so no code is needed to display the records Product record at all.

 That’s all there is to it!  I hope you find this post helpful.  Thanks for reading!





Jason Buss

Jason is a senior application developer with Customer FX.

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) news and product updates!

You have Successfully Subscribed!