CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviCase (Moderator: Dave Greenberg) »
  • a shared activity in 2 different cases?
Pages: [1]

Author Topic: a shared activity in 2 different cases?  (Read 2973 times)

Rémi

  • Guest
a shared activity in 2 different cases?
August 03, 2010, 04:10:48 am
Hi everybody,
I'm a beginner with CiviCRM and I'm planning to set CiviCRM for a small organisation.

I'm amazed by the functionalities and so I'm currently trying to understand the limits of CiviCRM!

I tried to figure out if there is a way to share an activity within 2 cases ?

It would look like this , with the cases being of different types:

 -----------------------------------------------------------------------
|                                                                                                  |
|   Contact1                                                         Contact2              |
|   Case 1        <=====>  Activity shared     <====>    Case 2               |
|                                                                                                  |
 -----------------------------------------------------------------------

By activity shared I mean that the activity appears in both cases and is sync ( when you modify it in one case its modified in the other).

Any ideas?

In fact the current behaviour of CiviCRM is a bit non-logical, as you can do

Contat1 <=========> Activity shared <===========> Contact2

(by using the field "with" and/or using the field "assigned to")

but using these fields for an activity inside a contact1 case wont change contact2 profile (ie the activity won't be on his/her list neither the case will be in his/her list).
This seems non-logical to me, at least for the "assigned to". I would say that if you assign somebody a case and/or an activity, he/she should be able to see it!


Is it a mistake or a choice?



this doesn't work :  

Contact1
Case  <============> Activity <=  ||  =>   contact2



Thank you for any insight !
Cheers, 8) 8)
Rémi



« Last Edit: August 03, 2010, 09:06:34 am by Rémi »

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: a shared activity in 2 different cases?
August 03, 2010, 11:18:38 am
I think I understand what you're asking but I'm not sure it does make sense to do it that way, e.g. suppose John is the case manager for both clients Mary and Steve. If I assign a followup to John because he needs to call Mary's supervisor on Monday, that shouldn't show up in Steve's case too because it has nothing to do with Steve.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: a shared activity in 2 different cases?
August 03, 2010, 02:26:30 pm
Quote from: Rémi on August 03, 2010, 04:10:48 am
but using these fields for an activity inside a contact1 case wont change contact2 profile (ie the activity won't be on his/her list neither the case will be in his/her list).
This seems non-logical to me, at least for the "assigned to". I would say that if you assign somebody a case and/or an activity, he/she should be able to see it!

Is it a mistake or a choice?

Cases with activities assigned to me will show up when I go to the Case -> Dashboard page as one of My Cases. This is the expected approach for staff (or volunteers) who are working on a case to "find" the activities they are supposed to work on. It is an explicit choice to display case activities INSIDE the case where they're entered. I think the reasoning is that case activities need the context of the case "story" to make sense.
Protect your investment in CiviCRM by  becoming a Member!

Rémi

  • Guest
Re: a shared activity in 2 different cases?
August 04, 2010, 03:13:48 am
thanks a lot for your answers !
I think I understand better now, and I share your points of view:

It makes sense that :
_sharing should be a choice. (demeritcowboy)
_an activity from a case should always be displayed within a case context (dave greenberg)

However for each activity within a case there are 2 buttons : "Move To Case | Copy To Case".

I guess that "Copy to case" is  designed as a non synchronised way of sharing an activity between 2 cases.
It would be really logical to have another option "Share to case", designed as a synchronised way of sharing activity between 2 cases *@*.

"Share to case" would do the same thing as "Copy to case" except that the activity would be shared ( any changes made would affect the activity for both of the owner).

Any idea how difficult it would be to develop such an option? ( I would guess not to difficult as it would be the same code than "copy to case" substituting the activity-creation code by a code to link to the right activity in the database.)

Thank you =)

PS: Oops, this message is very long, sorry  :-X :-X


here is an example of an user-case :
-----------------------------------------------------------------------------------------------------------------------------
my client is an organisation (lets call it GO) which has a branch in NY and a branch in LA. Both branches have the same way of working.
I would like to move GO to CiviCRM.
I will need  to perform 3 activities :
_install and customize CiviCRM to match GO's way of working.
_migrate the LA-branch's data
_migrate the NY-branch's data

I'm using CiviCRM and CiviCase to manage my work, so I should create a case for each branch, and share the first activity in the 2 cases.

contact : GO NY branch
Case : move NY-branch to CiviCRM
Activities :
_install and customize CiviCRM to match GO's way of working (shared)
_migrate the NY-branch's data

contact : GO LA branch
Case : move LA-branch to CiviCRM
Activities :
_install and customize CiviCRM to match GO's way of working (shared)
_migrate the LA-branch's data

------------------------------------------------------------------------------------------------------------------
I could create only one case (for GO as client) but it would be bad practices as case wouldn't be recorded in the GO NY-branch and GO LA-branch history.
This case is a bit stupid but IRL it happens often that part of the work is used for several clients, thus it should be designed as a shared activity in CiviCase



*@* : Maybe this option never was needed because the CiviCase was created for doctors, so the case would only relate to only one patient (as a legacy of it, you can assign a case only to one contact).




Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: a shared activity in 2 different cases?
August 04, 2010, 09:38:04 am
First, CiviCase is also being used by organizations where there can be multiple clients for a case. This usage pattern is not as common (since so far most users are in human service organizations which typically organize their work as one client per case). You can enable the multi-clients per case functionality by modifying this setting in the Settings.xml file for your site:

Code: [Select]
<!-- Set this to 1 if you want to allow multiple clients to be associated with a single case -->
<AllowMultipleCaseClients>0</AllowMultipleCaseClients>

Regarding "Share with (another) Case" action, the data model does support this option. If you're interested in sponsoring or contributing a patch to make this happen - I think we'd need to deal with the following issues:

1. I think this option would violate privacy rules in some case management environments - so there would need to be configuration parameter to enable / disable it (similar to the MultiClient switch).

2. We already have two many action links in the activity table from a usability / visual clutter perspective (View, Edit, Move to..., Copy to.. , Delete). Before we add one more action, I think we need to migrate the UI to the approach we use in other table listings, which is to have maximum of 2 actions and then a "more >" link which opens a pop-up with the remaining choices. This is do-able but according to our engineering lead a bit challenging in the context of the jquery widget we are using to list activities inside the Manage Case page.

If you have budget for the above, and are interested in pushing this and / or other enhancements forward let me know and we can put together a sizing / scope for it.

http://wiki.civicrm.org/confluence/display/CRM/Developing+with+the+CiviCRM+team
Protect your investment in CiviCRM by  becoming a Member!

Rémi

  • Guest
Re: a shared activity in 2 different cases?
August 05, 2010, 03:29:50 am
Hi,
thanks for the information  8)
I'm strongly interested in this "share with another case " option.
Although I have no budget ( or a laughable one ),
I do have time and (maybe enough) technical skills.

at the same time, the specs of my project require no custom code at all in CiviCRM (no hooks, etc.: it will be maintained by an "accidental Techie").

If I were to develop this functionality, would it be integrated into CiviCRM core (as a patch?)?

About the development maybe it's a good solution to not add any action link in the activity table, but instead to change the "Copy To Case" display ( what you view when you click on it), by adding a check-box ( like " share this activity between the 2 cases" ), like in O-Office or in M-Office when you insert an object, as an additional option.
This check box would (or wouldn't) be showed depending on the Settings.xml file.
I think this is a best practice as creating a special "share activity with another case" would be essentially a duplicate of the "copy to case" code, which is bad. And the "share with another case" doesn't seem so important to have it's own action link (I think this is an useful option, but for the moment it seems I'm the only one requesting it)


Maybe this discussion should be moved to the developer forum?
Btw I read the (very good) floss manual, but couldn't find explanations about CiviCRM 3.2 architecture (which files do what)
Anyway thank you all for your insights
 :) Rémi :)


------------------------------------------------------------------------------

If I'm trying to do a planning for the development,it would require:
_adding an option in Settings.xml
(say <AllowSharedActivities>, value 0 or 1)
_Modifying the xml parser so it recognize this new tag ( i guess)

_Change the "Copy To Case" display by adding a check-box called "share this activity between the 2 cases" displayed only if  <AllowSharedActivities>=1
_internationalize the check-box name : "share this activity between the 2 cases" for enabling different languages

_Modify the function called by the OK button when using the "copy to case" form, so if the checkboxe is checked, no new activity is created and instead an entry is added in the "civicrm_case_activity" MySQL table (or something like that) corresponding to a "link" between the case selected and the activity.

_check that deleting the case and/or the shared activity don't leave an orphan entry in the "civicrm_case_activity" (depending on how you the delete function is coded I guess).


The files to change are :

\CRM\Case\xml\configuration\Settings (ading the <AllowSharedActivities> tag)
\civicrm\CRM\Case\XMLProcessor\Process.php ( managing XML change in parsing)
\civicrm\templates\CRM\Case\Form\ActivityToCase.tpl (  adding a checkbox and changing the copy to case function)
(eventually, the files managing the delete of an activity/case)
-----------------------------------------------------------------------------------------------------------------------





« Last Edit: August 05, 2010, 04:52:50 am by Rémi »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: a shared activity in 2 different cases?
August 05, 2010, 12:28:53 pm
Hi Rémi - Your idea for how to handle the UI / workflow for this is good. We would be fine accepting a patch to 3.2 that adds this functionality conditional on presence of the <AllowSharedActivities> TRUE in Settings.xml (default will be false in the sample config copy).

Your list of "things to do" for coding also seems pretty complete. A few notes about business rules which you'll want to understand (and make sure they still work ... or fix) as you extend the code:

1. When a case activity is edited, the updated data is always inserted as a new "revision" of the activity row. The function that handles this may need to be modified to insert new case_activity rows for the new revision for any cases which share the activity being edited.

2. When a case activity is "deleted" - we don't actually delete the row, but rather set activity.is_deleted flag = 1. Deleting a shared activity would cause it to "disappear" from all cases that share it - and it probably would be good to add text the default delete warning indicating that the activity being deleted is shared with other case(s). If you need users to be able to delete from Case A, but not Case B - that obviously would require more UI / code.

I assume that activities can be shared between more than 2 cases - so I guess clicking Copy to Case + checking Share .... for a shared activity would add another case to the "shared set". Does their need to be a way to "un-share"?

Finally, I suspect folks will want to know that an activity is shared with another case (and have a llnk to that case) - minimally on the "Activity View" pop-up, but also potentially as a "read-only" piece of information / link to shared case on the activity edit form.

As you get into the details of the code, IRC is probably your best place to answer detailed questions.
Protect your investment in CiviCRM by  becoming a Member!

Rémi

  • Guest
Re: a shared activity in 2 different cases?
August 07, 2010, 07:50:02 am
Okay,
Thank you for letting me developing this and integrating it in CiviCase!

I'll start working on it for now.
I'm planning to finish it in 1 or 2 weeks, max 3 weeks.

IRC is a chat and I may have problem as obviously I'm not in the same time zone ( I'm in Europe).

For the functionalities, the least I'll do is a way to share activity with another case, and a display of shared case in the activity details.
If I can (depending on my understanding of CiviCRM), I'll try to develop an un-share method as well as other display.

I took a look at the CiviCRM activity / case tables in MySQL thanks to your warning about the revision system

I'll keep on touch.

 :DRémi :D

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: a shared activity in 2 different cases?
August 07, 2010, 09:37:03 am
Sounds good. Regarding IRC, we have core team members in Poland and India (as well as other active and knowledgeable folks in your hemisphere on IRC) - so timezone shouldn't be a problem for you. :-)
Protect your investment in CiviCRM by  becoming a Member!

Rémi

  • Guest
Re: a shared activity in 2 different cases?
August 16, 2010, 01:16:25 am
Up :
I was mapping my IS to CiviCRM, I'll start the development soon

The specs are refined :

_Activities in cases could be shared with more than 2 cases.
_The unshare option wont exist, for unsharing , just delet the activity in the cases concerned, then use copy to a case (eventually)
_the display of the cases the activity is shared with will be in the activity view (displayed when clicking on the activity subject).

Rémi

Rémi

  • Guest
Re: a shared activity in 2 different cases?
August 24, 2010, 04:35:05 am
I added the checkbox.
I'm now working on the xml tag <EnableSharedActivities> in the Settings.xml

According to my test the XMLProcessor (Process.php, function run) is not called.

In fact , I have the impression that the <AllowMultipleCaseClients>0</AllowMultipleCaseClients>
is of no use at all (the value won't change in the running programm when I change the tag).

Can somebody confirm that this <AllowMultipleCaseClients> is working (and maybe tell me when it's used?)

Any help would be greatly appreciated as I'm a bit stopped

Rémi :D





Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: a shared activity in 2 different cases?
August 24, 2010, 07:31:14 am

I checked the codebase and there is code to get this value

in CRM/Case/Form/Activity.php

whats your test where the function is not called? might want to chat with us on IRC, a bit easier and faster that way

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Rémi

  • Guest
Re: a shared activity in 2 different cases?
August 24, 2010, 04:59:41 pm
Thank you for your answer
( I tried IRC before posting  :) )

I put a javascript sample to open a popup (which I tested) in the "run" function in the crm_case_XMLProcessor_Process.php.
This popup was never trigered by my actions (maybe I did'n do the right action).

I thought about doing each time I needed the value something like :

 
Code: [Select]
$xmlProcessor = new CRM_Case_XMLProcessor_Process( );
    $isAllowSharedActivities = $xmlProcessorProcess->getAllowSharedActivities( );

I supposed it was bad practice as I guessed when creating a new instance it was parsing the xml settings each time. ( and I need the value each time an activity is showed inside a case !)

If reading xml file isn't a problem, fine!
Else what could I do to limit the reading ( reading only once, maybe when opening a new case, and the rest of the time don't read the xml file if the variable is set, else read and set the variable?)

AnyWay thank for the help

 8) Rémi 8)
            

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: a shared activity in 2 different cases?
August 24, 2010, 08:30:01 pm

yeah, unfortunately PHP does not store state during page requests. so we need to read the xml whenever we use it. Its either reading the xml file or storing in the DB and reading a DB table

We cache stuff, so once we've read the file, we dont reread it on another call

in the long run, putting this in memcached will solve the reading and parsing on every request issue

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviCase (Moderator: Dave Greenberg) »
  • a shared activity in 2 different cases?

This forum was archived on 2017-11-26.