Answers.Body: <p>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.</p>
  
  <p>Prerequisites:</p>
  
  <ol>
  <li>Views PHP module is installed</li>
  <li>In your webform, you have enabled/ticked 'Include link to edit webform submission in activity details'
  <img src="https://i.sstatic.net/ws3B6.jpg" alt="enter image description here"></li>
  </ol>
  
  <p>Steps:</p>
  
  <ol>
  <li><p>In the View of CiviCRM Activities, add 'CiviCRM Activities: Details' as a field to the view and tick 'Exclude from display'</p></li>
  <li><p>Add a new field 'Global: PHP' to the view, and paste the below content in Output code </p></li>
  </ol>
  
  <blockquote>
  <pre><code>&lt;?php
  preg_match_all('/&lt;a href=\"([^\"]*)\"&gt;Edit Submission&lt;\/a&gt;/iU', $row-&gt;details, $match);
  echo $match[0][0];
  ?&gt;
  </code></pre>
  </blockquote>
  
  <p>The above code will get the edit submission link from the activity details using regular expression and will display the link in the view.</p>
  
  <p>View Final Output:
  <img src="https://i.sstatic.net/oy02P.jpg" alt="enter image description here"></p>
  
  <p>Hope this helps.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T15:47:01.303Z
Answers.Text: 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.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T18:00:51.050Z
Answers.Text: 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.
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T14:56:54.047Z
Answers.LastActivityDate: 2015-06-18T15:05:18.257Z
Answers.LastEditDate: 2015-06-18T15:05:18.257Z
Answers.UserDisplayName: Ghost
Answers.Body: <p>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 <strong>Edit Activity</strong> form with every possible activity field on it and many conditionals to hide/show certain fields depending on the activity type.</p>
  
  <p>The final link is formed <a href="http://example.com/edit-activity?cid2=[id1]&amp;aid=[id]" rel="nofollow">http://example.com/edit-activity?cid2=[id1]&amp;aid=[id]</a>.</p>
  
  <p>Took a while to create the Edit Activity form but once we got that sorted, the rest was pretty easy.</p>
  
  <p>Thanks for all of the good ideas.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-10T20:07:15.380Z
Answers.LastActivityDate: 2016-04-10T20:07:15.380Z
Answers.UserDisplayName: pmoz
Answers.Body: <p>There's no way in Views to exclude activities that were <em>not</em> created with a webform. Hopefully limiting to certain activity type(s) will do it for you.</p>
  
  <p>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:</p>
  
  <ol>
  <li>Install the Views PHP module.</li>
  <li><p>Add a new field 'Global: PHP' to the view, and paste the below content in Output code:</p>
  
  <pre><code>&lt;?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-&gt;id};'"
  $wf = db_query($query)-&gt;fetchObject();
  if ($wf) {
    print "&lt;a href='/node/{$wf-&gt;nid}/submission/{$wf-&gt;sid}/edit'&gt;Edit&lt;/a&gt;";
  }
  ?&gt;
  </code></pre></li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T21:20:02.983Z
Answers.LastActivityDate: 2015-06-18T21:34:30.370Z
Answers.LastEditDate: 2015-06-18T21:34:30.370Z
Answers.UserDisplayName: Coleman
Answers.Body: <p>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.</p>
  
  <p>Then the url you could use <a href="http://yoursite.com/my-activity-webform?aid=" rel="nofollow">http://yoursite.com/my-activity-webform?aid=</a>...</p>
  
  <p>The parameter aid is the ID of the activity which you want to edit</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T15:41:12.473Z
Answers.Text: Does this solution require a different webform for each activity type?
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T20:37:17.640Z
Answers.Text: i would expect so as the drupal webform needs to be set up for a specific Activity Type doesn't it
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T20:47:22.920Z
Answers.Text: oh fudgesickles
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T20:56:49.967Z
Answers.Text: in the latest version of webform_civicrm the activity type can be user-select
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T02:23:10.873Z
Answers.Text: ah nice. good work as always coleman
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-08T00:16:38.270Z
Answers.Text: Yes, we've tried that and it leads to user input errors unfortunately.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T14:52:56.690Z
Answers.LastActivityDate: 2015-06-18T14:52:56.690Z
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
Tags: <activities><webform-civicrm><drupal-views>
Title: How to create a Drupal View of CiviCRM Activities with an edit link to the corresponding Webform?
ThreadText: # How to create a Drupal View of CiviCRM Activities with an edit link to the corresponding Webform?
  
  (Asked by: username_0 on 2015-06-18)
  
  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.
  
  **Tags:** activities, webform-civicrm, drupal-views
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2016-04-10. Score: 0 | Accepted answer
  
  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.
  
  
  ---
  
  ### Answer by username_1 on 2015-06-18. Score: 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](https://i.sstatic.net/ws3B6.jpg)
  
  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](https://i.sstatic.net/oy02P.jpg)
  
  Hope this helps.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_2**: 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.  
  
  ---
  
  ### Answer by username_3 on 2015-06-18. Score: 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>";
     }
     ?>
  
     ```
  
  
  ---
  
  ### Answer by username_2 on 2015-06-18. Score: 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
  
  > **Comments:**
  > **username_0**: Does this solution require a different webform for each activity type?  
  > **username_4**: i would expect so as the drupal webform needs to be set up for a specific Activity Type doesn't it  
  > **username_0**: oh fudgesickles  
  > **username_3**: in the latest version of webform_civicrm the activity type can be user-select  
  > **username_4**: ah nice. good work as always username_3  
  > **username_0**: Yes, we've tried that and it leads to user input errors unfortunately.  
  
  ---
  
  