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 XBar Installation
When installing the new XBar application I found the instructions a little vague so I thought I would pas
Posted on Jul 18, 2014 by Mark Duthoy to SalesLogix Support
 
   Finding the Current Parent Record ID in SalesLogix Web
Sometimes it's the easiest things that can be a big barrier to entry for getting started with somet
Posted on Jun 27, 2014 by Ryan Farley to Ryan Farley's Blog
 
   SalesLogix 8.1 Job Service Scheduling Executions Error Resolution
Often times a web implementation will have an application server that is used to deploy the web portals t
Posted on Jun 20, 2014 by Mark Duthoy to SalesLogix Support
 
   Saleslogix 8.1 Web Access Tab Throws Null Reference Error
 I recently had a client experiencing a problem access the Contact's Web Access tab.  Whene
Posted on Jun 18, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Debugging Custom Assemblies Using Visual Studio
Developing for Saleslogix web using external assemblies provides you with a lot of freedom when developin
Posted on Jun 10, 2014 by Jason Buss to Jason Buss' 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