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 Drupal Modules (Moderator: Donald Lobo) »
  • edit / view activity links in Drupal views
Pages: [1]

Author Topic: edit / view activity links in Drupal views  (Read 3147 times)

kennedy

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 5
  • CiviCRM version: 4.5.5
  • CMS version: Drupal
  • PHP version: 5.3.10
edit / view activity links in Drupal views
July 10, 2014, 04:46:18 am
Please help! I have a Drupal view listing some activities and i will like to add the edit and view links to the view.

In Drupal views there is a field called  CiviCRM Activities: Text Link with option to choose where to link the field but this gives me an error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'civicrm_activity.source_contact_id' in 'field list'

How to replicate error
- Create a view of type civicrm activities, add a relationship ( CiviCRM Activity Contacts: Activity Contact ID ), set the record type for this field to Activity targets.
- add some fields (display name, etc),
- add field CiviCRM Activities: Text Link and choose to link field to view activity.

Results => SQLSTATE[42S22]: Column not found: 1054 Unknown column 'civicrm_activity.source_contact_id' in 'field list'


Hints please !!! work around???

Using CiviCRm 4.4.6,




« Last Edit: July 10, 2014, 04:58:52 am by kennedy »

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: edit / view activity links in Drupal views
July 10, 2014, 06:16:07 am
Have you added db alias for civicrm db in settings.php ?

Kurund
Found this reply helpful? Support CiviCRM

kennedy

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 5
  • CiviCRM version: 4.5.5
  • CMS version: Drupal
  • PHP version: 5.3.10
Re: edit / view activity links in Drupal views
July 10, 2014, 06:45:18 am
Hi Kurund, if you are talking about the settings on this link /civicrm/admin/setting/uf?reset=1, Yes i have added.
The error message only shows up when i add this field CiviCRM Activities: Text Link and if the field is removed, i get the right results.

Thanks

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: edit / view activity links in Drupal views
July 10, 2014, 01:24:22 pm
kennedy - does the same link work in civi - i ask because in general i find that you cannot just go to an activity to edit it in civi - you also need eg the ID of the contact assigned etc

i think the only way i have been able to jump in to edit and activity is to do it via the ever useful WebformCivicrm module

I might be barking up the wrong tree - if the link you want to create in VIews does work in civi then guess the civi-views code needs looking at.
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

kennedy

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 5
  • CiviCRM version: 4.5.5
  • CMS version: Drupal
  • PHP version: 5.3.10
Re: edit / view activity links in Drupal views
July 10, 2014, 11:12:22 pm
Yes Pete, the links (edit and view) work just fine in civi. This seems to be a bug in the civi-views code, I have tested on two different installs civi4.4.3 and 4.4.6 both versions give the same error.

Here is a work around in Drupal views, maybe it can help someone too!
add two fields contact ID and Activity ID, exclude these two fields from display. Add a global custom text field and rewrite the output to an edit link see below:
<a href="example.com/civicrm/activity/add?atype=66&action=update&reset=1&id=[id_1]&cid=[id]&context=activity">EDIT</a>

And for the view link, civicrm/activity?atype=66&action=view&reset=1&id=[id_1]&cid=[id]&context=activity

atype = activity type ID which is a custom activity type in my case
[ID_1]= activity id 
[ID] = contact ID
« Last Edit: July 10, 2014, 11:46:08 pm by kennedy »

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: edit / view activity links in Drupal views
July 11, 2014, 04:10:42 pm
kennedy i think we might be saying the same thing - but i didn't explain it well

the workaround you provided, or something similar, is what i expected is required since i thought you needed to have the ID and the CID etc, and no single Views field can give that as far as i can see, because it won't have that context.

ie in past i didn't think you could eg 'edit' an activity without a url that includes cid in it

but my quick test just now showed i did get there without the cid in which case a tweak to the views code might suffice (not offering though)
if there is then yes perhaps the views code can cope with that

but if not, then perhaps the 'text link' can be removed from the Views field so others don't get false expectations.

(not sure i am being very articulate but have rewritten this three times now - sorry)
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

ericg

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.3.x - 4.5.x
  • CMS version: drupal 6 and 7
  • MySQL version: 5.1 and 5.5
  • PHP version: 4.3
Re: edit / view activity links in Drupal views
February 14, 2015, 03:41:38 pm
I just hit this problem upon upgrading a site from 4.3.x to 4.5.x

somewhere between the versions I was moving from and to the civicrm_activity table was altered and the column source_contact_id was deleted and data was moved to civicrm_activity_contact
 (line 616 of the file CRM/Upgrade/Incremental/php/FourFour.php deletes the table)

but the views handler is still calling the now missing column when trying to make the activity text link field

I don't know enough about views handlers to know where to start fixing this (adding in the table, join and correct field definition) but I don't think it would be hard for someone that already understands the mechanics of it all

the workaround stated above does work, but it would be nice of this field worked like it did in earlier versions

ericg

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.3.x - 4.5.x
  • CMS version: drupal 6 and 7
  • MySQL version: 5.1 and 5.5
  • PHP version: 4.3
Re: edit / view activity links in Drupal views
February 15, 2015, 10:16:07 am
I have found the fix for this and will submit a patch in the next few days. For anyone finding this page while searching for a fix, here's the answer:

the heavy lifting of doing the necessary join to the table introduced in 4.4 was already done, but civicrm_handler_field_link_activity.inc was still calling the pre 4.4 schema/looking for a column in the db that no longer exists.

so, first, comment out or delete line 49
    //  $this->additional_fields['contact_id'] = 'contact_id';

then change the link to use
cid={$values->civicrm_contact_civicrm_activity_contact_id}
instead of
cid={$values->civicrm_activity_source_contact_id}

on lines 114, 123 and 132

your links should be correctly formatted and no longer throw errors

ericg

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.3.x - 4.5.x
  • CMS version: drupal 6 and 7
  • MySQL version: 5.1 and 5.5
  • PHP version: 4.3
Re: edit / view activity links in Drupal views
February 15, 2015, 10:30:28 am
arg, my fix only works in some situations not all,

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: edit / view activity links in Drupal views
March 05, 2015, 02:15:17 am
I'm guessing the reason why it works in some cases and not all is that the edit link needs the CID of the activity source and not the CID of the record in the current row of the view. (it will work when that row happens to be pertaining to the activity source) - the source is now identified through the 'Record Type' attribute of Activity Contacts rather than as an attribute of Activity.

I was thinking of using a views_php field as a workaround but then I realised that my view filters out the source of the activity  ::)
« Last Edit: March 05, 2015, 02:26:16 am by myles »

ericg

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.3.x - 4.5.x
  • CMS version: drupal 6 and 7
  • MySQL version: 5.1 and 5.5
  • PHP version: 4.3
Re: edit / view activity links in Drupal views
April 08, 2015, 05:11:57 pm
changed the view link to use
cid={$values->civicrm_contact_civicrm_activity_contact_1_id}

and it works as expected now

ericg

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.3.x - 4.5.x
  • CMS version: drupal 6 and 7
  • MySQL version: 5.1 and 5.5
  • PHP version: 4.3
Re: edit / view activity links in Drupal views
April 08, 2015, 05:13:58 pm
and from this issue it seems that this problem will be resolved in 4.6
https://issues.civicrm.org/jira/browse/CRM-15008

:)

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: edit / view activity links in Drupal views
April 30, 2015, 03:06:43 am
Thanks for pointing that out - I'll have another go :-)

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: edit / view activity links in Drupal views
April 30, 2015, 12:54:38 pm
note Jira is unresolved - fix for 4.7 - ericg can you supply your patch as a PR?
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

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: edit / view activity links in Drupal views
May 01, 2015, 12:41:10 am
Are you sure that rig's solution will work in all cases?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • edit / view activity links in Drupal views

This forum was archived on 2017-11-26.