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 (Moderator: Dave Greenberg) »
  • View only custom data field purpose?
Pages: [1]

Author Topic: View only custom data field purpose?  (Read 3034 times)

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
View only custom data field purpose?
April 29, 2010, 02:00:13 pm
I am trying to figure out the use for a View Only custom data field ... if the field is marked as View Only, then you cannot add any data to it either manually or using the API which makes it basically useless!

What good is a field that you cannot add any data? Or am I missing how it should be used!

Thanks

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: View only custom data field purpose?
April 29, 2010, 02:04:31 pm
The description below VIEW ONLY? is:

    Is this field set by PHP code (via a custom hook). This field will not be updated by CiviCRM.

This field type is intended to be set via a hook. And of course hooks CAN set the value.
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.

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
Re: View only custom data field purpose?
April 29, 2010, 02:15:25 pm
This is worded poorly because it starts with the word 'Is' like its asking a question ... I don't understand it ...
"Is this field set by PHP code (via a custom hook). This field will not be updated by CiviCRM."

Should it instead read: "This field is set by PHP ..." ??

Is there any docs on how to set it from PHP in a hook?

What about forcing the API to change it (currently API cannot create or update a view only field)?

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: View only custom data field purpose?
April 29, 2010, 02:21:04 pm
I have used this hook: http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcustomFieldOptions to set the options for View Only custom fields. The other hook that should be able to do this is http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmbuildForm
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.

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
Re: View only custom data field purpose?
April 29, 2010, 02:35:32 pm
Ok thanks I will take a look at those!

EDIT: Ok, I took a look but I don't see how either hook lets me add/modify data in a View Only field? I must not be understanding how it is to be used or what it is for!
« Last Edit: April 29, 2010, 02:37:30 pm by jsherk »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: View only custom data field purpose?
April 29, 2010, 07:40:21 pm

IMO, you should use:

CRM_Core_BAO_CustomValueTable::setValues

to set values of custom fields including hidden fields.

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
Re: View only custom data field purpose?
April 29, 2010, 08:05:43 pm
Will this allow you to set Custom fields that are View Only (not hidden) as well?

Thanks

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: View only custom data field purpose?
April 29, 2010, 10:50:46 pm
yes, you can use CRM_Core_BAO_CustomValueTable::setValues
to set/update value for view only custom fields.

kiran
« Last Edit: April 29, 2010, 11:00:15 pm by Kiran Jagtap »
You Are Designed To Choose... Defined By Choice.

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
Re: View only custom data field purpose?
April 30, 2010, 04:31:49 am
Is that the only way that a View Only field can be set/modified, or are there other ways as well?

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: View only custom data field purpose?
April 30, 2010, 04:35:21 am
IMO you can give default value at the creation which might going to work.

kiran
You Are Designed To Choose... Defined By Choice.

jsherk

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 0
Re: View only custom data field purpose?
April 30, 2010, 05:03:03 am
Ok I see... I did not notice the default value setting before!

Thanks

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • View only custom data field purpose?

This forum was archived on 2017-11-26.