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) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • How to change custom field input from "text" to "select" (dropdown select)
Pages: 1 [2]

Author Topic: How to change custom field input from "text" to "select" (dropdown select)  (Read 2106 times)

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to change custom field input from "text" to "select" (dropdown select)
July 10, 2014, 11:24:59 am
Sorry, Jon ... never used Pastebin. 

http://pastebin.com/vmabUzPU

Carl

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: How to change custom field input from "text" to "select" (dropdown select)
July 10, 2014, 11:51:05 am
No worries!  So you know, you don't need to use a Pastebin account for public pastes.  And now that we have that error message, I'm pretty sure I see the problem!

If you look at the pastebin, you'll see the SQL being executed that is throwing the error:
SELECT count(*)
FROM   civicrm_custom_field
WHERE  option_group_id =

So it seems that you need to find the entry in civicrm_custom_field that corresponds to the field you modified, and enter a value for option_group_id.  That value should correspond to the entry in civicrm_option_group that stores your multiple-choice values for the field.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to change custom field input from "text" to "select" (dropdown select)
July 10, 2014, 01:15:16 pm
Jon,

Okay, I'm getting closer, but looks like I'm still missing something.

The entry in civicrm_custom_field that corresponds to the field I modified is: "NSA_Qualification" (the unique custom field ID is 16, and the custom group ID is 3.)

Looking at custom group ID 3 in CiviCRM_custom_group shows a table, civicrm_value_sailing_qualifications_3, where the values for the SQL Select should be stored according to your last message.

Then going to table civicrm_value_sailing_qualifications_3, I see a column named, "nsa_qualification_16" for which there are many rows with orginal values that came from the imported DB that contains some dirty data (hence wanting to use drop-downs going forward).  The 2 selection options that I tried to create from civicrm Admin are nowhere to be found. So I'm lost at this point at a dead-end road. ;-)   

??Where?? am I to enter the option group id so that it will be found by the SQL statement?  And what do I put there? "3"? 

Sorry, I'm lost at this point, but I think I got close ... what now?

Carl

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: How to change custom field input from "text" to "select" (dropdown select)
July 10, 2014, 02:31:52 pm
Carl,

It looks like you were looking at civicrm_custom_group, but I was referring to civicrm_option_group.  Could you look again, this time at civicrm_option_group?

Please pastebin the following:
select id, name, label, option_group_id FROM civicrm_custom_field WHERE id = 16;

My understanding is that in that SQL, option_group_id will be NULL, but it has to have a value corresponding to your multiple choice options in civicrm_option_group.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to change custom field input from "text" to "select" (dropdown select)
July 10, 2014, 03:55:02 pm
Jon,

Looking at the option_group, and not the civicrm_custom_group (duh)  the option_group_id is NULL.

It would make sense that the field is NULL because creation of the options was never successful when saving, but rather resulted in the error, right?

Here's the query:
http://pastebin.com/mpJGvwy5

Carl



CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: How to change custom field input from "text" to "select" (dropdown select)
July 11, 2014, 08:44:57 am
Hershel's idea is how I would suggestion it be done - in this case.

1. export the custom text data
2. clean up the text data (normalize it)  (i.e. orange, oranges, ornge all become 'orange')
3. create new select field
4. import into that field
Try CiviTeacher: the online video tutorial CiviCRM learning library.

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: How to change custom field input from "text" to "select" (dropdown select)
July 11, 2014, 09:43:50 am
Civiteacher is on to something!

I have an idea that entering the next available civicrm_option_group id would do the trick, but I'm not in a position to spend time figuring out if that would do damage.  I think the import option is probably safest at this point.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

cfusch

  • I post occasionally
  • **
  • Posts: 44
  • Karma: 1
  • CiviCRM version: 4.6.6
  • CMS version: Drupal 7.39
  • MySQL version: 5.6.23
  • PHP version: 5.4.38
Re: How to change custom field input from "text" to "select" (dropdown select)
July 11, 2014, 10:20:05 am
 Yeah, if I'd done what Hershel suggested, I'd be done by now even with the remaining 20 or so columns like it!  :-[   I'll move on with his suggested method.

I'll also try adding the next in line ID just for grins, and will do it in my own backyard, then report it back to you guys at a later date.

{ Sorry, Hershel ... Next time I'll move swiftly forward with your suggestions. }

Carl


Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: How to change custom field input from "text" to "select" (dropdown select)
July 13, 2014, 10:27:40 am
Yes, on occasion I do have good ideas.

Anyhow this thread may be useful for others in the future. :)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: How to change custom field input from "text" to "select" (dropdown select)
July 13, 2014, 03:06:11 pm
so another option to consider (maybe for others in the future) would be to see if Views Bulk Operations and the civicrm entities module can let you eg search for all contacts with eg "oran" and then set the new field for them to be "orange" if that is the scenario

can't quite recall if civicrm entities has been taken as far as updating custom fields but
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • How to change custom field input from "text" to "select" (dropdown select)

This forum was archived on 2017-11-26.