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) »
  • Trying to get activity types for contact component only
Pages: [1] 2

Author Topic: Trying to get activity types for contact component only  (Read 3157 times)

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Trying to get activity types for contact component only
June 08, 2013, 11:44:19 pm
I am trying to grab all activity types for the contact component.

The

$result = civicrm_api( 'activity_type','get',$params );

seems to return all activity types and there is no information returned here to filter.
Guessing that I need to check each one separately - just cannot figure out how.

Or maybe there is another way?
--
Nick (aka nant from CB Team)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Trying to get activity types for contact component only
June 09, 2013, 02:44:50 pm
You might want to  query the option_value table for activity types first - the component_id field will tell you what they relate to (to some extent)
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

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 10, 2013, 02:28:30 am
Quote from: Eileen on June 09, 2013, 02:44:50 pm
You might want to  query the option_value table for activity types first - the component_id field will tell you what they relate to (to some extent)

Is there an API example to do this?
--
Nick (aka nant from CB Team)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Trying to get activity types for contact component only
June 10, 2013, 02:49:30 am
There is an optionValueGet example in the examples directory - (api/v3/examples in your install). Not in the example - it also takes a param 'option_group_name' => 'activity_type'
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

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 10, 2013, 05:10:04 am
Quote from: Eileen on June 10, 2013, 02:49:30 am
There is an optionValueGet example in the examples directory - (api/v3/examples in your install). Not in the example - it also takes a param 'option_group_name' => 'activity_type'

Forgot to thank you for responding before - THANK YOU!

I am trying this:


         $params = array(
            'option_group_name'   => 'activity_type'
         );

         $opt = array('version' => 3, 'name' => $params['option_group_name']);
         $optionGroup = civicrm_api('OptionGroup', 'Get', $opt);
         if (empty($optionGroup['id'])) {
            return civicrm_api3_create_error("option group name does not correlate to a single option group");
         }
         $params['option_group_id'] = $optionGroup['id'];

I do not see anything useful returned in the $optionGroup variable.
--
Nick (aka nant from CB Team)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Trying to get activity types for contact component only
June 10, 2013, 05:28:26 am
Hi,

if the component id isn't set, it isn't displayed, that's only when you have it different than you get it, eg:

If you filter out all activity types that have the component set, you should get the list you want
Code: [Select]
{
"id":"10",
"option_group_id":"2",
"label":"Event Registration",
"value":"5",
"name":"Event Registration",
"filter":"1",
"weight":"5",
"description":"Online or offline event registration.",
"is_optgroup":"0",
"is_reserved":"1",
"is_active":"1",
"component_id":"1"
},
{
"id":"11",
"option_group_id":"2",
"label":"Contribution",
"value":"6",
"name":"Contribution",
"filter":"1",
"weight":"6",
"description":"Online or offline contribution.",
"is_optgroup":"0",
"is_reserved":"1",
"is_active":"1",
"component_id":"2"
},
{
"id":"12",
"option_group_id":"2",
"label":"Membership Signup",
"value":"7",
"name":"Membership Signup",
"filter":"1",
"weight":"7",
"description":"Online or offline membership signup.",
"is_optgroup":"0",
"is_reserved":"1",
"is_active":"1",
"component_id":"3"
},
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 10, 2013, 04:29:10 pm
Quote from: xavier on June 10, 2013, 05:28:26 am
Hi,

if the component id isn't set, it isn't displayed, that's only when you have it different than you get it, eg:

If you filter out all activity types that have the component set, you should get the list you want
Code: [Select]
{
"id":"10",
"option_group_id":"2",
"label":"Event Registration",
"value":"5",
"name":"Event Registration",
"filter":"1",
"weight":"5",
"description":"Online or offline event registration.",
"is_optgroup":"0",
"is_reserved":"1",
"is_active":"1",
"component_id":"1"
},
{
"id":"11",
"option_group_id":"2",
"label":"Contribution",
"value":"6",
"name":"Contribution",
"filter":"1",
"weight":"6",
"description":"Online or offline contribution.",
"is_optgroup":"0",
"is_reserved":"1",
"is_active":"1",
"component_id":"2"
},
{
"id":"12",
"option_group_id":"2",
"label":"Membership Signup",
"value":"7",
"name":"Membership Signup",
"filter":"1",
"weight":"7",
"description":"Online or offline membership signup.",
"is_optgroup":"0",
"is_reserved":"1",
"is_active":"1",
"component_id":"3"
},

Thanks for replying - sorry but I am not understanding what I should do to get what you are showing above.
--
Nick (aka nant from CB Team)

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 13, 2013, 12:13:28 am
follow-up for those still with me ...

The code:

         $params = array(
            'version'   => 3,
            'name'      => 'activityType'
         );
         $at = civicrm_api('constant', 'get', $params);

returns 26 values array:

1 = "meeting"
2 = "Phone Call"
3 = "Email"
4 = "Text Message (SMS)"
5 = "Event Registration"
6 = "Contribution"
7 = "Membership Signup"
8 = "Membership Renewal"
9 = "Tell a Friend"
10 = "Pledge Acknowledgment"
11 = "Pledge Reminder"
12 = "Inbound Email"
17 = "Membership Renewal Reminder"
19 = "Bulk Email"
22 = "Print PDF Letter"
34 = "Mass SMS"
35 = "Change Membership Status"
36 = "Change Membership Type"
37 = "Cancel Recurring Contribution"
38 = "Update Recurring Contribution Billing Details:
39 = "Update Recurring Contribution"
40 = "Reminder Sent"
41 = "Export Accounting Batch"
42 = "Create Batch"
43 = "Edit Batch"
55 = "test"

The code:

$params = array(
            'version'   => 3
         );
         $j2c_system_activity_types = civicrm_api('activityType','get', $params);

returns the following 50 values

1 = "meeting"
2 = "Phone Call"
3 = "Email"
4 = "Text Message (SMS)"
5 = "Event Registration"
6 = "Contribution"
7 = "Membership Signup"
8 = "Membership Renewal"
9 = "Tell a Friend"
10 = "Pledge Acknowledgment"
11 = "Pledge Reminder"
12 = "Inbound Email"
13 = "Open Case"
14 = "Follow up"
15 = "Change Case Type"
16 = "Change Case Status"
17 = "Membership Renewal Reminder"
18 = "Change Case Start Date"
19 = "Bulk Email"
20 = "Assign Case Role"
21 = "Remove Case Role"
22 = "Print PDF Letter"
23 = "Merge Case"
24 = "Reassigned Case"
25 = "Link Cases"
26 = "Change Case Tags"
27 = "Add Client To Case"
28 = "Survey"
29 = "Canvass"
30 = "PhoneBank"
31 = "WalkList"
32 = "Petition Signature"
33 = "Change Custom Data"
34 = "Mass SMS"
35 = "Change Membership Status"
36 = "Change Membership Type"
37 = "Cancel Recurring Contribution"
38 = "Update Recurring Contribution Billing Details:
39 = "Update Recurring Contribution"
40 = "Reminder Sent"
41 = "Export Accounting Batch"
42 = "Create Batch"
43 = "Edit Batch"
44 = "Medical evaluation"
46 = "Mental health evaluation"
48 = "Secure temporary housing"
50 = "Income and benefits stabilization"
52 = "Long-term housing plan"
54 = " ADC referral"
55 = "test"

So your code does narrow things down alot - however I am trying to get down to the list that is shown in backend UI when I go to an Individual profile and select the Activity tab to create a new activity.
In this case I see in the New Activity drop down:

Send a mail
Meeting
Phone Call
Print PDF Letter
test

also thinking that maybe creating a Send a mail activity does not actually send an email - is this correct?
--
Nick (aka nant from CB Team)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Trying to get activity types for contact component only
June 13, 2013, 12:33:39 am
I don't understand, you don't get component_id?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 13, 2013, 12:35:07 am
Quote from: xavier on June 13, 2013, 12:33:39 am
I don't understand, you don't get component_id?

That is correct - non of these api calls return component_id
--
Nick (aka nant from CB Team)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Trying to get activity types for contact component only
June 13, 2013, 02:26:19 am
It doesn't make sense. Can you try running the same two api calls with the api explorer on your site?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 13, 2013, 02:37:10 am
Quote from: xavier on June 13, 2013, 02:26:19 am
It doesn't make sense. Can you try running the same two api calls with the api explorer on your site?

api explorer?
--
Nick (aka nant from CB Team)

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 13, 2013, 04:11:48 am
Quote from: nant on June 13, 2013, 02:37:10 am
Quote from: xavier on June 13, 2013, 02:26:19 am
It doesn't make sense. Can you try running the same two api calls with the api explorer on your site?

api explorer?

API explorer is Drupal only - is it not?
--
Nick (aka nant from CB Team)

nant

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 4
    • Joomlapolis
  • CiviCRM version: 4.3.4
  • CMS version: Joomla 2.5.11
  • MySQL version: 5
  • PHP version: 5.3
Re: Trying to get activity types for contact component only
June 13, 2013, 05:36:50 am
Quote from: xavier on June 13, 2013, 02:26:19 am
It doesn't make sense. Can you try running the same two api calls with the api explorer on your site?

Ok, found the api explorer (had to watch your video ;-) )

Same results from explorer - only list of names are returned.
--
Nick (aka nant from CB Team)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Trying to get activity types for contact component only
June 14, 2013, 02:22:02 am
Quote from: nant on June 13, 2013, 05:36:50 am
Ok, found the api explorer (had to watch your video ;-) )

Was this that painful ? ;)

The api call that returns the component info is
/civicrm/ajax/rest?entity=OptionValue&action=get&debug=1&sequential=1&json=1&option_group_name=activity_type

Code: [Select]
$params = array(
  'version' => 3,
  'sequential' => 1,
  'option_group_name' => 'activity_type',
);
$result = civicrm_api('OptionValue', 'get', $params);
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Trying to get activity types for contact component only

This forum was archived on 2017-11-26.