Login / Register  search  syndication  about

          Kris Halsrud's Blog

Kris Halsrud on development and Integration with CRM and Development

Sales Order Bill To Ship To tab will not work properly when contacts have more than one of the same address description

 I recently was asked about a problem in the SalesLogix web client where the Bill To Ship To tab throws an error if either the Bill To or Ship To contact has more than one address with the same description.

 

If you look at the load event of the form you can see it is using a code action item like this:

        System.Web.UI.WebControls.ListItem billingItem;
        lstbxBillingAddress.Items.Clear();
        if (salesOrder.BillingContact != null)
        {
            System.Collections.Generic.IList<Sage.Entity.Interfaces.IAddress> billingAddresses = Sage.Platform.EntityFactory.GetRepository<Sage.Entity.Interfaces.IAddress>().FindByProperty("EntityId", salesOrder.BillingContact.Id.ToString());
            if (billingAddresses != null)
            {
                foreach (Sage.Entity.Interfaces.IAddress address in billingAddresses)
                {
                    billingItem = new System.Web.UI.WebControls.ListItem();
                    billingItem.Text = address.Description;
                    billingItem.Value = address.Id.ToString();
                    billingItem.Selected = address.Description.Equals(salesOrder.BillingAddress.Description);
                    lstbxBillingAddress.Items.Add(billingItem);
                }
            }
        }

The problem is in the line shown above in red, where the are selecting the address in the list based on if it is the same description as the sales order's address.  Since this is a single select list box it will not allow you to multi-select the same description if it exists.

A work around is to handle catching if an address has already been selected. Like so:

            System.Web.UI.WebControls.ListItem billingItem;
            lstbxBillingAddress.Items.Clear();
            if (salesOrder.BillingContact != null)
            {
                Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.IAddress> repository = Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.IAddress>();
                Sage.Platform.Repository.ICriteria criteria = repository.CreateCriteria();
                criteria.Add(repository.EF.Eq("EntityId", salesOrder.BillingContact.Id.ToString()));
                criteria.AddOrder(repository.EF.Asc("Description"));
                System.Collections.Generic.IList<Sage.Entity.Interfaces.IAddress> billingAddresses = criteria.List<Sage.Entity.Interfaces.IAddress>();

                //System.Collections.Generic.IList<Sage.Entity.Interfaces.IAddress> billingAddresses = Sage.Platform.EntityFactory.GetRepository<Sage.Entity.Interfaces.IAddress>().FindByProperty("EntityId", salesOrder.BillingContact.Id.ToString());
                if (billingAddresses != null)
                {
                    bool selection = false;
                    foreach (Sage.Entity.Interfaces.IAddress address in billingAddresses)
                    {
                        billingItem = new System.Web.UI.WebControls.ListItem();
                        billingItem.Text = address.Description;
                        billingItem.Value = address.Id.ToString();
                        if (address.Description.Equals(salesOrder.BillingAddress.Description) && !selection)
                        {
                            billingItem.Selected = true;
                            selection = true;
                        }

                        lstbxBillingAddress.Items.Add(billingItem);
                    }
                }
            }

The pertinent changes to the code are shown in red. 

Also note, in the green lines, I have also modified the code to retrieve the list of addresses sorted alphabetically by description, unlike the OOTB screen which has no sort.

A pretty easy fix to make to the screen to let you work with contacts having the same description.  If you do have a lot of the same descriptions for addresses, it might be worth adding some additional descriptive information into the list, like

billingItem.Text = address.Description + " - " + address.City;

What's This?
  
Bookmark and Share

About Kris Halsrud

   Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.


Related Content
   Saleslogix (now Infor CRM) Web Client- Build Error Based on Quick Form Name
 I recently discovered a problem that will occur if you happen to name a quick form the same name as
Posted on Oct 31, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Unicode Character Sets for SalesLogix Web 8.1
If you have the need to use unicode character sets so international users can view the web client in thei
Posted on Oct 29, 2014 by Mark Duthoy to SalesLogix Support
 
   Change the Appearance of a Saleslogix (Now Infor CRM) Read Only TextBox Web Control
In the Salelogix web client, a read only control has a css style applied to it to make the background app
Posted on Oct 24, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Saleslogix (now Infor CRM) Web Client- Changing Label Appearances on Quick Forms
 I wrote previously about setting a label's appearance on a quick form using server side code.&n
Posted on Oct 02, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Error Attempting to Save an Entity: "E_FAIL(0x80004005)" in the Infor CRM (Saleslogix) Web Client
We recently had a client that was running into an issue when attempting to create one particular entity i
Posted on Sep 30, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2014 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register