CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • state_province_name key is empty on civicrm_api('contact', 'get', $params)?
Pages: [1]

Author Topic: state_province_name key is empty on civicrm_api('contact', 'get', $params)?  (Read 982 times)

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
state_province_name key is empty on civicrm_api('contact', 'get', $params)?
July 08, 2014, 03:01:39 pm
I am just testing some simple custom code that calls the api after an upgrade to 4.4.6. In this code we used to use the 'state_province_name" key on the contact array. This key is set in the array but is coming up as an empty  string after the upgrade. The "state_province" key is not empty. It does contain the short name of the province indicating that the contacts do have primary address. I know I have used this key before to get the State/Province long name. Is there a setting perhaps that I am missing in address preferences?
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
July 08, 2014, 03:11:48 pm
what did you upgrade from? if 4.4.x that sounds odd. I wouldn't be surprised if the behaviour had changed from 4.3 - I did push pretty hard to maintain consistency in the api but I'm sure some changes snuck through around the edges - especially in untested parameters
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
July 08, 2014, 03:35:04 pm
Thanks for answering Eileen. This was an upgrade from way back...4.2.9.
It does look to me like this field is not tested based on this: https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php

Edited to add: The same thing is happening on the demo site using the api explorer for any contact with a primary address, the location type doesn't seem to matter.
« Last Edit: July 08, 2014, 03:44:28 pm by lolas »
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
July 21, 2014, 01:42:26 am
Yes, I am finding that {contact.state_province_name} works using the Civi user interface in the address display but not in the mailing labels format, whereas {contact.state_province} continues to work fine in both. ???

I am using Civi 4.4.6 on Drupal 7.29

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
October 21, 2014, 02:35:40 am
Under 4.5.2, the state_province_name field is still elusive for mailing labels, meaning that address labels come out just with the short acronym (eg "PA" rather than "Pennsylvania")

You can see this on the demo site, by using the API explorer to Get all the fields for a contact:
http://d45.demo.civicrm.org/civicrm/api/explorer
Where a contact has a valid state_province, it shows the same shortened version for state_province_name, whereas I think it should show the long version of the state there.

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
October 21, 2014, 03:52:07 am
I have filed this as an issue on 4.5.2 with a suggested fix here:
https://issues.civicrm.org/jira/browse/CRM-15505

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
October 21, 2014, 11:55:13 am
Stuart - you say that {contact.state_province}  works fine in both - what is the problem with just using that? If we change the result coming out of the Query object then code (custom & core) that is adapted to current behaviour will be affected so I think we need to potentially add a parameter or use a different one
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
October 22, 2014, 12:55:09 am
Eileen. I am using Civi in the UK, where we need the full state/province name (which we actually call "county") on mailings. The 2/3 letter acronym, which is well used in the US, is totally unheard of here in the UK and so completely useless in addressing letters. The postman would know where Surrey is, but would be flummoxed by SRY!

Also, {contact.state_province_name} used to work correctly. It's only in recent versions of Civi that it's started giving the shortened version. So I don't think there will be much adaptive code around.

joanne

  • Administrator
  • Ask me questions
  • *****
  • Posts: 852
  • Karma: 83
  • CiviCRM version: 4.4.16
  • CMS version: Drupal 7
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
October 22, 2014, 04:15:27 am
I thought that County was basically superfluous in the UK as far as mail is concerned:

http://www.postoffice.co.uk/how-to-address-mail?intcampaignid=MNmailaddressmail say:

Quote
you don’t need to write the name of the county if you have included the post town and postcode


Stuart Parker

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 2
  • CiviCRM version: 4.5.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.63
  • PHP version: 5.2.14
Re: state_province_name key is empty on civicrm_api('contact', 'get', $params)?
October 22, 2014, 05:43:19 am
Well, yes it is. But in a recent change to the list of state/provinces in Civi, "Greater London" was changed to "London". So unless you want "London, London" (which looks messy), you need to rely on the state/province field for the City in at least this case.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • state_province_name key is empty on civicrm_api('contact', 'get', $params)?

This forum was archived on 2017-11-26.