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) »
  • Assign Activity via API
Pages: [1]

Author Topic: Assign Activity via API  (Read 850 times)

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Assign Activity via API
March 22, 2014, 03:09:56 pm
Anyone have any idea how you assign an activity via the API, so that the contact who the activity is assigned to receives an e-mail in the same way that they do when using the GUI?

Brian

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Assign Activity via API
March 22, 2014, 04:09:37 pm
The main "Activity" API includes some under-documented params to manipulate the relationship between the contact and activity. For example, this creates a new activity with various contacts:

https://github.com/civicrm/civihr/blob/e3047e251e60c1df3cfb6c5face390555ff6dc2a/hrabsence/CRM/HRAbsence/Form/AbsenceRequest.php#L454

I believe there are parallel "return" options (eg "return.assignee_contact_id" => 1) for use when fetching activities.

As far as how that ties into emails... I'm not sure which email you're referring to. Could be:
 * If you've configured scheduled reminders for activities, then they'll work the same regardless of how one creates/edits the activity.
 * If you're using CiviCase and its built-in notifications, then I don't know the answer off the top of my head.
 * If you're trying to create activities of type "Email" which are then sent out, then I don't think there's an API, but there's a function to create the activity and send the message at once (CRM_Activity_BAO_Activity::sendEmail). One could probably write a new API (wrapping around that function) without too much difficulty.

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Assign Activity via API
March 22, 2014, 05:21:44 pm
The email I am referring to is on any Activity screen. Click on New Activity, and there is an Assigned To line. You can type in a contact name there, and when you save the activity, that contact receives an e-mail notification of the Activity.

I'll look into the link you gave.

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Assign Activity via API
May 06, 2014, 10:43:25 am
I'm able to assign an Activity to a contact using the API, but unfortunately this doesn't result in the system generated e-mail that is sent when assigning an Activity to a contact using the GUI. Is there anyway to do that?

I'd prefer to have the activity in an e-mail than have to use a hook to send a link to the activity, which would require a user login for a mobile device etc.

Brian

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Re: Assign Activity via API
May 09, 2014, 05:58:30 am
Quote from: bpmccain on May 06, 2014, 10:43:25 am
I'm able to assign an Activity to a contact using the API, but unfortunately this doesn't result in the system generated e-mail that is sent when assigning an Activity to a contact using the GUI. Is there anyway to do that?

Not sure if that will help you but maybe you can sue scheduled reminders to trigger the email after assigning the activity.

capo

  • I post occasionally
  • **
  • Posts: 108
  • Karma: 5
Re: Assign Activity via API
May 09, 2014, 06:00:28 am
By the way, since 4.5 you'll have the ActivityContact API entity, too (CRM-14414), so you'll have a second way to assign activities. (I guess the email won't probably be sent either, anyway).

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Assign Activity via API
May 12, 2014, 03:14:55 pm
If we wind up doing an LTS on 4.4 I'm sure that will go into the LTS too
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Assign Activity via API

This forum was archived on 2017-11-26.