3

Goal is to have a filterable and sortable Drupal View of CiviCRM Activities (not a view of Webform Submissions) created with a Webfom with a link to edit the webform submission.

I can painstakingly do it through the Views UI if I create the View as a view of Webform Submissions, but the inability to filter/sort on fields is a deal breaker.

If I create a View of CiviCRM Activities, I get all of the filter and sort options but no nice link to edit the webform.

4

There is no straight forward way to get the 'Edit Submission' link in the View of CiviCRM Activities. Below is a workaround where we extract the 'Edit Submission' link from activity details.

Prerequisites:

  1. Views PHP module is installed
  2. In your webform, you have enabled/ticked 'Include link to edit webform submission in activity details' enter image description here

Steps:

  1. In the View of CiviCRM Activities, add 'CiviCRM Activities: Details' as a field to the view and tick 'Exclude from display'

  2. Add a new field 'Global: PHP' to the view, and paste the below content in Output code

<?php
preg_match_all('/<a href=\"([^\"]*)\">Edit Submission<\/a>/iU', $row->details, $match);
echo $match[0][0];
?>

The above code will get the edit submission link from the activity details using regular expression and will display the link in the view.

View Final Output: enter image description here

Hope this helps.

  • 1
    Trying to avoid the link to Edit Webform Submissions in Activity Details as the details of the activity are the main content of the view. Having that link in the details field is not the desired result.I should have added that to my question. – pmoz Jun 18 '15 at 15:47
  • I would not include Edit submission, I would rather create a different link in the view and call it edit activity because the data is in CiviCRM and not neccesarly in the webform submissions. – Jaap Jansma - CiviCooP Jun 19 '15 at 18:00
2

There's no way in Views to exclude activities that were not created with a webform. Hopefully limiting to certain activity type(s) will do it for you.

As for getting the link to the webform submission. This data is stored in a serialized field (which is therefore quite hard to query). Here's an (untested) way you might get at it:

  1. Install the Views PHP module.
  2. Add a new field 'Global: PHP' to the view, and paste the below content in Output code:

    <?php
    $query = "SELECT cs.sid, s.nid FROM {webform_civicrm_submissions} cs, {webform_submissions} s WHERE s.sid = cs.sid AND cs.data LIKE '\"activity\";a:1:{i:1;a:1:{s:2:\"id\";i:{$row->id};'"
    $wf = db_query($query)->fetchObject();
    if ($wf) {
      print "<a href='/node/{$wf->nid}/submission/{$wf->sid}/edit'>Edit</a>";
    }
    ?>
    
1

In your webfor you specify a path e.g. my-activity-webform and you enable CiviCRM processing with an activity. You have to select an activity type and also select a type under Update Extsiting.

Then the url you could use http://yoursite.com/my-activity-webform?aid=...

The parameter aid is the ID of the activity which you want to edit

  • Does this solution require a different webform for each activity type? – pmoz Jun 18 '15 at 15:41
  • i would expect so as the drupal webform needs to be set up for a specific Activity Type doesn't it – petednz - fuzion Jun 18 '15 at 20:37
  • oh fudgesickles – pmoz Jun 18 '15 at 20:47
  • in the latest version of webform_civicrm the activity type can be user-select – Coleman Jun 18 '15 at 20:56
  • ah nice. good work as always coleman – petednz - fuzion Jun 19 '15 at 2:23
0

Ended up creating a view of Activities with a custom field to edit this activity. This link includes cid2 (the client) and aid (the activity) and points to an Edit Activity form with every possible activity field on it and many conditionals to hide/show certain fields depending on the activity type.

The final link is formed http://example.com/edit-activity?cid2=[id1]&aid=[id].

Took a while to create the Edit Activity form but once we got that sorted, the rest was pretty easy.

Thanks for all of the good ideas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.