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 »
  • Using CiviCase (Moderator: Dave Greenberg) »
  • Correct API syntax for custom CiviCase field
Pages: [1]

Author Topic: Correct API syntax for custom CiviCase field  (Read 748 times)

allenthehusband

  • I’m new here
  • *
  • Posts: 27
  • Karma: 2
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • PHP version: 5.3
Correct API syntax for custom CiviCase field
August 19, 2014, 01:45:50 pm
I'm trying to get the value of a custom field on to a CiviCase activity screen (using \templates\CRM\Case\Form\Activity.tpl).  I've tried calling the API using both Case and CustomValue entities, but have been unsuccessful thus far.  Here are the bits of info relevant to my custom field, titled 'Background Check'.

From our Custom Data screen(s), the custom group ID to which our field belongs is 15.  The ID of the custom field itself is 44.
From our API parameters page (URL/civicrm/api/doc#case), the field is custom_44.
From our mySQL database, the custom group table is civicrm_value_ministry_application_15.  The column name is background_check_44.

I've used the API explorer with both Case and CustomValue, but the closest I've gotten is with CustomValue:

Code: [Select]
/civicrm/ajax/rest?entity=CustomValue&action=get&debug=1&sequential=1&json=1&entity_id=$caseId&return.custom_44=1
In the explorer with the above code, I can at least get the values to populate for "entity_id", "latest", "id" and "0", but the trouble is that when I use the Smarty equivalent of that call, I get an error message saying that the return.custom_44=1 is not expected syntax.

When I've used the Contact API on other TPL files, I had to use (for example) "&return=custom_7" and it worked great, but I've tried "&return=custom_44" with both the Case and CustomValue entities, and neither return the relevant info.

I feel like I have all the pieces I would need to get the value of the field, I just don't know the proper syntax to use for a call to the Case API.  Can someone point me in the right direction?  Thanks so much!

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Correct API syntax for custom CiviCase field
August 19, 2014, 02:01:15 pm
I think in smarty you can just say return=custom_44
Try asking your question on the new CiviCRM help site.

allenthehusband

  • I’m new here
  • *
  • Posts: 27
  • Karma: 2
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • PHP version: 5.3
Re: Correct API syntax for custom CiviCase field
August 19, 2014, 02:07:30 pm
Coleman, thanks so much for your quick reply.  Here's what I've just put into my TPL file, but it does not return the value.  Any ideas?

Code: [Select]
{crmAPI var='result' entity='Case' action='get' sequential=1 case_id=$caseId return=custom_44}
{foreach from=$result.values item=Case}
{$Case.background_check_44.field_value}
{/foreach}

allenthehusband

  • I’m new here
  • *
  • Posts: 27
  • Karma: 2
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • PHP version: 5.3
Re: Correct API syntax for custom CiviCase field
August 19, 2014, 03:10:50 pm
I've also tried

{$Case.background_check_44}
{$Case.custom_44}

with no luck.  I'm stumped.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Correct API syntax for custom CiviCase field
August 20, 2014, 01:21:15 am
That param is a string. Strings need to be quoted. So, return='custom_44'
Try asking your question on the new CiviCRM help site.

sandeepmohanty

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.32
  • MySQL version: 5.5.40
  • PHP version: 5.3.10
Re: Correct API syntax for custom CiviCase field
February 20, 2015, 03:52:02 am
I am getting ajax error while i am adding case type as field in drupal view. I am using drupal version 7.34 and civicrm version 4.5.5. It shown in screen-shot.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Correct API syntax for custom CiviCase field
February 20, 2015, 06:03:58 am
That's a views issue not an api issue. Can you try clearing your caches? Are you using the latese version of CiviCRM?
Try asking your question on the new CiviCRM help site.

sandeepmohanty

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.32
  • MySQL version: 5.5.40
  • PHP version: 5.3.10
Re: Correct API syntax for custom CiviCase field
February 22, 2015, 10:34:19 pm
Quote from: Coleman Watts on February 20, 2015, 06:03:58 am
That's a views issue not an api issue. Can you try clearing your caches? Are you using the latese version of CiviCRM?


Yes i cleared views caches and drupal caches. I am using civicrm 4.5.5 version and drupal views version is 3.10

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: Correct API syntax for custom CiviCase field
February 22, 2015, 10:35:49 pm
seems the above user may have clicked on 'report to moderator'

sandeep was that on purpose or just an accident?
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]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviCase (Moderator: Dave Greenberg) »
  • Correct API syntax for custom CiviCase field

This forum was archived on 2017-11-26.