Answers.Body: <p>What I have found is that to update an existing activity that is part of an existing case, it is insufficient to pass just the activity ID into the form via the URL. Which sort of makes sense as I can't see where that data would be stored in the webform submission (maybe it somehow gets passed into CiviCRM via the url?) </p>
  
  <p>However, if I pass in the contact ID of the case client as well, and use an additional hidden existing contact field in the webform for this ID, as explained by @jaap-jansma in the comments elsewhere on this page, then this is enough data for CiviCRM to be able to identify the correct target activity in the correct case, and update the activity accordingly.</p>
  
  <p>Maybe we don't need to pass in the activity ID at all, given that we can target the correct case, and use the filters available in webform_civicrm to focus on updating the correct activity? If I have time I'll test that option, and would welcome comments from others on this.</p>
  
  <p>We used a Drupal View to construct and present the link to the user.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T09:57:52.500Z
Answers.Text: We are having some issues with activities submitted through a webform, Graham, did you have to enable case processing for this to work?
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T13:09:36.577Z
Answers.Text: @pmoz I did have case processing enabled. It made sense in my use case.  Can you share more detail about the issues you are seeing?
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T15:24:28.747Z
Answers.Text: Better description of my issues here: http://civicrm.stackexchange.com/questions/5117/webform-created-for-case-activity-and-multiple-case-types?noredirect=1#comment6098_5117
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-20T08:41:28.433Z
Answers.LastActivityDate: 2015-06-20T08:41:28.433Z
Answers.UserDisplayName: Graham
Answers.Body: <p>I don't think you can pass case id in the url.</p>
  
  <p>I sort of asked a similar question here:
  <a href="http://forum.civicrm.org/index.php/topic,36136/" rel="nofollow" title="Using webform-civicrm to update cases by case-id">http://forum.civicrm.org/index.php/topic,36136</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-20T08:28:12.283Z
Answers.Text: Hmm, not sure about this. The code certainly appears to include reference to "caseid", but I'm not sure where it would be stored in the form as there's no option to include a case id field.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T00:19:47.870Z
Answers.LastActivityDate: 2015-06-18T00:19:47.870Z
Answers.UserDisplayName: pmoz
Answers.Body: <p>This is possible at the option update existing case and update existing activity. This option is available after you have enabled case and activity processing.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-15T11:35:40.483Z
Answers.Text: Thanks Jaap. I have activity processing enabled. Do I need to have case processing enabled as well?
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-15T12:00:21.670Z
Answers.Text: @jaap_jansma If I enable case processing then it looks like I need to specify the case client, which in this instance is totally irrelevant. Can I avoid this?
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T06:39:40.677Z
Answers.Text: I would welcome some more detail on this, as I'm not able to get the webform to update an activity. I can create an activity without a problem.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T07:17:39.897Z
Answers.Text: I would think you need the case processing. When the webforms gets to complicated I usually create a drupal view just before the webform and then on the webform I would also a 2nd contact, which is the client of the case. And from the view I pass the cid2=... in the url parameter. So that this contact is prefilled.
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-15T11:16:33.717Z
Answers.LastActivityDate: 2015-06-15T11:16:33.717Z
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.Body: <p>I added a case to the webform and passed the case1 id via the URL.</p>
  <p>I made sure the Case Type was &quot;User Select&quot; so CiviCRM does not expect to have case roles added, except for the case client. This was critical. When I selected a case type, the activity kept getting added instead of updated.</p>
  <p>I passed the case client CID as a hidden contact on the webform,</p>
  <p>I made sure the activity was File on Case  'Case1'</p>
  <p>I made sure all the target, source and assignees bits were filled out on the activity.</p>
  <p>I passed the activity id in the URL to populate the activity.</p>
  <p>I passed CIDs for the target, source and assignee to populate the activity.</p>
  <p>This magic sauce prevents an activity being added, when you want to update an existing one.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-30T11:52:08.420Z
Answers.LastActivityDate: 2021-03-30T12:46:04.373Z
Answers.LastEditDate: 2021-03-30T12:46:04.373Z
Answers.UserDisplayName: Tony Horrocks
Body: <p>Here's the scenario:</p>
  
  <p>A user submits a webform that creates a case.</p>
  
  <p>An administrator assigns a role in that case to a second user, and edits a specific activity (activity ID = xxx) in that case to assign that activity to the same user named for the role.</p>
  
  <p>A Drupal View is used to present to that second user a link to a different webform. The link is of the form <a href="http://example.org/path/to/form?aid=xxx" rel="nofollow">http://example.org/path/to/form?aid=xxx</a> 
  My understanding is that because I have appended the activity ID to the url the form submission will update the activity with that ID.</p>
  
  <p>However, when I submit the form a new activity gets created and the activity with ID = xxx is not updated or affected in any way.
  It doesn't seem to matter which options I set for the activity within the webform.
  Where am I going wrong?</p>
  
  <p>As a supplementary, I've noticed that for the activity that does get created (with ID = yyy), if I file that activity on the case where it should be, then the filed activity has a different ID (yyy+1), which is concerning. Surely an activity should retain the same ID number regardless of its status?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-15T21:08:15.923Z
Comments.Text: I've tried to achieve the activity update using many different permutations of settings on both activity and case processing tabs, still with no success. I can get it to create a new activity with no problem, but with a new activity created I can't get that activity to be filed on my target case, despite providing the case ID in the url. Surely I'm missing something obvious here?
Comments.UserDisplayName: Graham
Tags: <activities><civicase><webform-civicrm>
Title: How do I setup a webform so that an existing activity in a case is updated?
ThreadText: # How do I setup a webform so that an existing activity in a case is updated?
  
  (Asked by: username_0 on 2015-06-15)
  
  Here's the scenario:
  
  A user submits a webform that creates a case.
  
  An administrator assigns a role in that case to a second user, and edits a specific activity (activity ID = xxx) in that case to assign that activity to the same user named for the role.
  
  A Drupal View is used to present to that second user a link to a different webform. The link is of the form <http://example.org/path/to/form?aid=xxx>
  My understanding is that because I have appended the activity ID to the url the form submission will update the activity with that ID.
  
  However, when I submit the form a new activity gets created and the activity with ID = xxx is not updated or affected in any way.
  It doesn't seem to matter which options I set for the activity within the webform.
  Where am I going wrong?
  
  As a supplementary, I've noticed that for the activity that does get created (with ID = yyy), if I file that activity on the case where it should be, then the filed activity has a different ID (yyy+1), which is concerning. Surely an activity should retain the same ID number regardless of its status?
  
  **Tags:** activities, civicase, webform-civicrm
  
  > **Comments:**
  > **username_0**: I've tried to achieve the activity update using many different permutations of settings on both activity and case processing tabs, still with no success. I can get it to create a new activity with no problem, but with a new activity created I can't get that activity to be filed on my target case, despite providing the case ID in the url. Surely I'm missing something obvious here?  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2015-06-20. Score: 1 | Accepted answer
  
  What I have found is that to update an existing activity that is part of an existing case, it is insufficient to pass just the activity ID into the form via the URL. Which sort of makes sense as I can't see where that data would be stored in the webform submission (maybe it somehow gets passed into CiviCRM via the url?)
  
  However, if I pass in the contact ID of the case client as well, and use an additional hidden existing contact field in the webform for this ID, as explained by @jaap-jansma in the comments elsewhere on this page, then this is enough data for CiviCRM to be able to identify the correct target activity in the correct case, and update the activity accordingly.
  
  Maybe we don't need to pass in the activity ID at all, given that we can target the correct case, and use the filters available in webform\_civicrm to focus on updating the correct activity? If I have time I'll test that option, and would welcome comments from others on this.
  
  We used a Drupal View to construct and present the link to the user.
  
  > **Comments:**
  > **username_1**: We are having some issues with activities submitted through a webform, username_0, did you have to enable case processing for this to work?  
  > **username_0**: @username_1 I did have case processing enabled. It made sense in my use case.  Can you share more detail about the issues you are seeing?  
  > **username_1**: Better description of my issues here: http://civicrm.stackexchange.com/questions/5117/webform-created-for-case-activity-and-multiple-case-types?noredirect=1#comment6098_5117  
  
  ---
  
  ### Answer by username_1 on 2015-06-18. Score: 1
  
  I don't think you can pass case id in the url.
  
  I sort of asked a similar question here:
  [http://forum.civicrm.org/index.php/topic,36136](http://forum.civicrm.org/index.php/topic,36136/ "Using webform-civicrm to update cases by case-id")
  
  > **Comments:**
  > **username_0**: Hmm, not sure about this. The code certainly appears to include reference to "caseid", but I'm not sure where it would be stored in the form as there's no option to include a case id field.  
  
  ---
  
  ### Answer by username_2 on 2015-06-15. Score: 1
  
  This is possible at the option update existing case and update existing activity. This option is available after you have enabled case and activity processing.
  
  > **Comments:**
  > **username_0**: Thanks Jaap. I have activity processing enabled. Do I need to have case processing enabled as well?  
  > **username_0**: @jaap_jansma If I enable case processing then it looks like I need to specify the case client, which in this instance is totally irrelevant. Can I avoid this?  
  > **username_0**: I would welcome some more detail on this, as I'm not able to get the webform to update an activity. I can create an activity without a problem.  
  > **username_2**: I would think you need the case processing. When the webforms gets to complicated I usually create a drupal view just before the webform and then on the webform I would also a 2nd contact, which is the client of the case. And from the view I pass the cid2=... in the url parameter. So that this contact is prefilled.  
  
  ---
  
  ### Answer by username_3 on 2021-03-30. Score: 1
  
  I added a case to the webform and passed the case1 id via the URL.
  
  I made sure the Case Type was "User Select" so CiviCRM does not expect to have case roles added, except for the case client. This was critical. When I selected a case type, the activity kept getting added instead of updated.
  
  I passed the case client CID as a hidden contact on the webform,
  
  I made sure the activity was File on Case 'Case1'
  
  I made sure all the target, source and assignees bits were filled out on the activity.
  
  I passed the activity id in the URL to populate the activity.
  
  I passed CIDs for the target, source and assignee to populate the activity.
  
  This magic sauce prevents an activity being added, when you want to update an existing one.
  
  
  ---
  
  