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
   Confirming Actions With an "Are you sure?" Prompt in Infor CRM (Saleslogix)
I'm not a huge fan of bugging end users. I figure, if an end user clicked something, he or she meant
Posted on Nov 18, 2014 by Ryan Farley to Ryan Farley's Blog
 
   Manipulating the DependencyLookup Control in the Infor CRM Web Client (Formerly Saleslogix)
 The Dependency Lookup control in the Saleslogix web client is what is used for the hierarchical Are
Posted on Nov 14, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Infor CRM (formerly Saleslogix) Statement of Direction
Learn more about the future of Infor CRM. Recently I received my login information for the Infor Partn
Posted on Nov 13, 2014 by Brianna Ojard to The Inbox
 
   Adding a report link to the Common Tasks pane in Infor CRM (formerly Saleslogix)
When you are viewing an Entity Detail page, the Common Tasks pane on the right of the page provides a nu
Posted on Nov 12, 2014 by Jason Buss to Jason Buss' Blog
 
   How to Sum a Collection using Hibernate Criteria and Projections
 To sum the results of a criteria collection you can use code such as the following, which gets the
Posted on Nov 07, 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