Setting the Order Contact's Address State field
Setting the Order Contact's Address State field
The address state field on an order contact does not accept a string value anymore. How do I set this field programmatically?
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: Setting the Order Contact's Address State field
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
Sr. Software Architect
SoftPro
Re: Setting the Order Contact's Address State field
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.
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"))?
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"))?
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: Setting the Order Contact's Address State field
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.
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
Sr. Software Architect
SoftPro
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: Setting the Order Contact's Address State field
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
Sr. Software Architect
SoftPro
Re: Setting the Order Contact's Address State field
Okay. Thanks.