2

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.

2 Answers 2

2

Please have a look at the extension Activity Type ACL.
Gitlab-site HERE

4
  • 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!
    – Alan Dixon
    Commented Apr 10 at 13:41
  • 1
    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).
    – Guitarman
    Commented Apr 10 at 16:48
  • Yes, that sounds like a terrible way to implement their requirements.
    – Alan Dixon
    Commented Apr 11 at 17:20
  • Not everyone has the time or the ability to write a custom extension or the possibilty to pay for the development of one.
    – Guitarman
    Commented Apr 16 at 16:04
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".

  1. 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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