I wanted to be able to get a constituent’s address from their record. Sounds simple enough. You just take the address block, the city, the state and zip. Although what happens if they are not in the States or Canada. When you change the country for example, to United Kingdom, the state field disappears and a county field appears in its place. Pulling the state field would just be a blank value.
Clearly you could write a few if…then statements based on the country but this is not really very elegant. What is more you can set up very many countries in the international area of Config. I looked in IBBUtilityCode to see if there was some function already there but no there was not. It was when I searched the knowledgbase that I found the answer.
Public Sub GetAddressBlock()
Dim oRecord As CRecord
oRecord = New CRecord oRecord.Init(REApplication.SessionContext) oRecord.Load(280) Debug.Print(oRecord.PreferredAddress.Fields(CONSTIT_ADDRESS_fld_FULLADDRESS)) oRecord.CloseDown() oRecord = Nothing End Sub
I can take no credit for this simple piece of code. It is straight from the knowledgebase (ID BB304478). How come I had never seen this before? Attached to knowledgebase article is a note that says:
The CONSTIT_ADDRESS_fld_FULLADDRESS is a hidden field, so it won’t show using intellisense.
If you put the full qualifier in .NET e.g. ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_FULLADDRESS you do see it. I do wonder how many more useful hidden features there are.