Answers.Body: <p>Please have a look at the extension <a href="https://civicrm.org/extensions/activity-type-acl" rel="nofollow noreferrer">Activity Type ACL</a>.<br/>
  Gitlab-site <a href="https://lab.civicrm.org/extensions/activitytypeacl" rel="nofollow noreferrer">HERE</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-10T13:41:23.663Z
Answers.Text: To be clear - that extension does not provide the functionality you're looking for, but may be helpful in creating a custom extension for what you are requesting. Installing that extension is likely to be very confusing!
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-10T16:48:42.153Z
Answers.Text: What user17427 tried to achieve is the restriction of editing/deleting an activity through civirules, see question tag. This wouldn't be possible. But what CAN be achieved using Activity Type ACL is that the deletion/editing of activities for certain userroles/activity types can be avoided, and that out-of-the-box. What could be achieved in combination with CiviRules, is i.e. the automated setting of a custom activity status after act. had been completed, as well as the automated assignment of the triggering contact to a usergroup, which can't be edited through the resp. personnel (Civi-ACL).
Answers.UserDisplayName: Guitarman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-11T17:20:52.590Z
Answers.Text: Yes, that sounds like a terrible way to implement their requirements.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-16T16:04:53.607Z
Answers.Text: Not everyone has the time or the ability to write a custom extension or the possibilty to pay for the development of one.
Answers.UserDisplayName: Guitarman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-03T11:32:45.507Z
Answers.LastActivityDate: 2024-04-03T11:32:45.507Z
Answers.UserDisplayName: Guitarman
Answers.Body: <p>You would need to do that in a custom extension. The Activity Type ACL may be useful for some example code, though it's a lot more complicated than what you need, provides a lot of stuff you don't want, and doesn't actually do what you're asking for.</p>
  <p>Your custom extension would need to:</p>
  <ol>
  <li><a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/</a></li>
  </ol>
  <p>Define a permission &quot;edit completed activities&quot;.</p>
  <ol start="2">
  <li><a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/</a></li>
  </ol>
  <p>Hook into all of the activities forms, test if it's completed and whether the user has the above permission, and generate an error if it's not allowed.</p>
  <p>I believe most of the 'delete activity' workflows go through the edit screen, so this might be enough.</p>
  <p>Here are the examples of these hooks being implemented by the activity acl extension: <a href="https://lab.civicrm.org/extensions/activitytypeacl/-/blob/master/activitytypeacl.php" rel="nofollow noreferrer">https://lab.civicrm.org/extensions/activitytypeacl/-/blob/master/activitytypeacl.php</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-10T13:47:10.517Z
Answers.LastActivityDate: 2024-04-10T13:47:10.517Z
Answers.UserDisplayName: Alan Dixon
Body: <p>I want to create an action in extension without form processing, which will restrict editing and deleting the activity of a contact after activity status is changed to 'Completed'. Please help me. I used CiviCRM Actions---&gt; Contacts.</p>
  
Tags: <civirules>
Title: Restricting editing and deleting an activity
ThreadText: # Restricting editing and deleting an activity
  
  (Asked by: username_0 on 2024-04-03)
  
  I want to create an action in extension without form processing, which will restrict editing and deleting the activity of a contact after activity status is changed to 'Completed'. Please help me. I used CiviCRM Actions---> Contacts.
  
  **Tags:** civirules
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-04-03. Score: 2
  
  Please have a look at the extension [Activity Type ACL](https://civicrm.org/extensions/activity-type-acl).  
  Gitlab-site [HERE](https://lab.civicrm.org/extensions/activitytypeacl)
  
  > **Comments:**
  > **username_2**: To be clear - that extension does not provide the functionality you're looking for, but may be helpful in creating a custom extension for what you are requesting. Installing that extension is likely to be very confusing!  
  > **username_1**: What username_0 tried to achieve is the restriction of editing/deleting an activity through civirules, see question tag. This wouldn't be possible. But what CAN be achieved using Activity Type ACL is that the deletion/editing of activities for certain userroles/activity types can be avoided, and that out-of-the-box. What could be achieved in combination with CiviRules, is i.e. the automated setting of a custom activity status after act. had been completed, as well as the automated assignment of the triggering contact to a usergroup, which can't be edited through the resp. personnel (Civi-ACL).  
  > **username_2**: Yes, that sounds like a terrible way to implement their requirements.  
  > **username_1**: Not everyone has the time or the ability to write a custom extension or the possibilty to pay for the development of one.  
  
  ---
  
  ### Answer by username_2 on 2024-04-10. Score: 1
  
  You would need to do that in a custom extension. The Activity Type ACL may be useful for some example code, though it's a lot more complicated than what you need, provides a lot of stuff you don't want, and doesn't actually do what you're asking for.
  
  Your custom extension would need to:
  
  1. <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/>
  
  Define a permission "edit completed activities".
  
  2. <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/>
  
  Hook into all of the activities forms, test if it's completed and whether the user has the above permission, and generate an error if it's not allowed.
  
  I believe most of the 'delete activity' workflows go through the edit screen, so this might be enough.
  
  Here are the examples of these hooks being implemented by the activity acl extension: <https://lab.civicrm.org/extensions/activitytypeacl/-/blob/master/activitytypeacl.php>
  
  
  ---
  
  