Setting the Order Contact's Address State field

Discussions related to custom development with Select.
Post Reply
ckootg
Posts: 122
Joined: Fri Jan 06, 2012 6:10 pm

Setting the Order Contact's Address State field

Post by ckootg »

The address state field on an order contact does not accept a string value anymore. How do I set this field programmatically?
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Setting the Order Contact's Address State field

Post by John Morris »

Using the fieldcode browser, you can see that the state field is of the datatype "IState". This is an enumeration value from the SoftPro.Select.Client.Enumerations namespace. These enumerated values are known as "drop down lists" in the SPAdmin area. Since these values can be customized, you need to interact with the IEnumManager to set that given value. Something like this:

Code: Select all

var sps = new SelectServer("http://localhost:8080");
var enums = sps.GetService<IEnumManager>();
var states = enums.GetEnum<IState>();
var nc = states.Values.FirstOrDefault(i => i.Code == "NC");
.
.
.
order.Properties[0].Address.State = nc; //assuming order is a dynamic variable referencing an order
John Morris
Sr. Software Architect
SoftPro
ckootg
Posts: 122
Joined: Fri Jan 06, 2012 6:10 pm

Re: Setting the Order Contact's Address State field

Post by ckootg »

Thank you for the explanation. I did see that the field was an IState field and an enumeration of SoftPro.Select.Client.Enumerations. And I did look in SPAdmin, hoping to find a "manager", but had no luck. These are the only "drop down lists" in my SPAdmin.
SPAdminDropDownLists.png
SPAdminDropDownLists.png (19.84 KiB) Viewed 1074 times
Am I missing some lists? I also looked under Lookup Tables, where I found "Zip Code", which contains fields for Zip, City, and State, yet there were no entries.

These lists are static, so would they be cached (during start-up or first use perhaps)? If they are cached, would there be another way to access those values without going back to the server (new SelectServer("http://localhost:8080"))?
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Setting the Order Contact's Address State field

Post by John Morris »

The State enumeration is considered a "system" list, so it is filtered from the dropdown list editor. The user cannot edit this one.

You can look at the SelectDb.zref.State db table to see the contents of the enumeration. Keep in mind, we do not support direct manipulation of db tables, so only use the table as a reference, not for making changes.
John Morris
Sr. Software Architect
SoftPro
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Setting the Order Contact's Address State field

Post by John Morris »

Also, the enum manager takes care of caching the enumeration values. You are not actually hitting the server on every call to the IEnumManager. So feel free to use it as needed.
John Morris
Sr. Software Architect
SoftPro
ckootg
Posts: 122
Joined: Fri Jan 06, 2012 6:10 pm

Re: Setting the Order Contact's Address State field

Post by ckootg »

Okay. Thanks.
Post Reply