2

I am trying to use the Civi API within a Drupal view, in the global PHP field.

It is all working, except for when I try to use an "Available Variable" from the view, it throws and error. When I hard code the variable's value, it works, though.

The variable I am using does contain the correct data; if I return just that variable, it returns the ID it should.

The code:

civicrm_initialize();
$start_date = civicrm_api3('price_field', 'getvalue', array(
  'return' => 'active_on',
  'price_set_id' => $row->price_set_id,
));

return gettype($start_date);'

Error field active_on unset or not existing

I am using Drupal 7 and CiviCRM 4.6.28.

  • you can access Price field data by installing CiviCRM Entity and its sub module CiviCRM Entity Views Extra – jackrabbithanna Jul 10 '17 at 23:13
  • I tried that...it's still not showing up in the view as a field. – Kimberlie Davis Jul 10 '17 at 23:19
  • You have to add 2 Views relationships. CiviCRM Price Set Entities: Price Set (Price Set) Price Field: Price Field – jackrabbithanna Jul 10 '17 at 23:27
  • You may need the Date Views module installed as well – jackrabbithanna Jul 10 '17 at 23:31
  • Okay, that worked. Thank you very much for your help. I'm still fairly new to Drupal, and views confuse me sometimes. But, that makes alot of sense now. – Kimberlie Davis Jul 10 '17 at 23:37
1

As far as your API call there goes...I don't see an 'id' => $row->price_field_id in there. You'll need to query by id to get the value for each individual price field. I'm not exactly sure what the variable name on the object will be in your case...but the main thing is to query for the individual price fields data by id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.