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) »
  • Adding the address of the target to the mail sent with Activity
Pages: [1]

Author Topic: Adding the address of the target to the mail sent with Activity  (Read 2641 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Adding the address of the target to the mail sent with Activity
December 21, 2011, 11:24:43 am
Bit of a challenge, which I do have a solution for but it is a bit hackish....so any more structured alternative is very welcome!

The use case: we have guys out in our neighborhood meeting with our customers and doing all sort of stuff. Part of what they do is triggered from the activities they are assigned in CiviCRM. They receive an email, which they can see on their mobile phones. For example, the back office receives a call from a customer saying he needs someone to come over and inspect leakage in the house. The technical guy receives the email and could go to the customer concerned without getting back to the office. However, it would be a huge improvement if they would also see the address of the customer, which is not in the standard message template.

So I thought I would solve it by changing the standard message template Cases - Send Copy of an Activity. I would have to add a token to hold the address of the customer, which I could do with the token hook. If I then use the tokenValue hook however, I only get the contactId of the assignee id and NOT the id of the customer involved. What I am going to do now is use the API to retrieve all the acitivities of the assignee and assume I need the latest activity, and retrieve the address of the first target.
That will probably work for my specific need, but it is a little hackish.............any better suggestions?
 
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

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: Adding the address of the target to the mail sent with Activity
December 21, 2011, 05:33:23 pm

Hey Erik:

Can u investigate and submit a patch that assigns the target_contact_ids, names to the template.

The relevant code is:

CRM/Activity/Form/Activity.php, near line 1048. You might wnt to get all target ids nd names in one call
CRM/Case/BAO/Case.php - function sendActivityCopy

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Adding the address of the target to the mail sent with Activity
December 26, 2011, 06:42:08 am
And with the ids of the assigned, you can use the smarty {crmAPI} in the mail template I'm quite sure.

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Adding the address of the target to the mail sent with Activity
December 27, 2011, 01:03:22 am
Lobo, will have a look at the best solution and raise an issue for it.
X, obviously the API can do all sorts of magic almost everywhere :-), and will certainly use the {crmAPI} in the mail template once I have the targetted Ids.
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Adding the address of the target to the mail sent with Activity
December 29, 2011, 11:05:00 pm
1) I'll second (or third) the point about using Smarty and APIv3 instead of the token hooks. It's more flexible and (when there are multiple entities floating around) clearer.

2) When using "Scheduled Reminders" to generate per-activity emails, I encountered a similar issue. I initially tried using {crmAPI} to lookup target/assignee contacts based on the activity_id, but that proved cumbersome. (I needed to do multiple lookups -- and to use the same sequence of lookups in several different email templates). This led to a hack called {simpleActivityContacts}, as in:

Code: [Select]
{simpleActivityContacts activity_id=$activity.activity_id}
Hello, {$assignee.display_name}, you should talk to {$target.display_name}.

That particular Smarty function probably shouldn't be publicized, but it may be an interesting example.

3) If the activities are managed through CiviCase, you might use client_id in lieu of target_contact_id or activity_id.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Adding the address of the target to the mail sent with Activity
December 30, 2011, 03:01:41 am
@totten: I will have to do a small change to the BAO first to pass on the targetId's concerned first, thanks for the Smarty function :-)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Adding the address of the target to the mail sent with Activity

This forum was archived on 2017-11-26.