Skip to main content

Hello,

175780710820071228174401.jpg


This is a WorkFlow example. I want to expire the activity 1 and 3 when i execute  "Synchroniser le circuit".

173398017420071228175405.jpg 

The server event : "Fermer toutes les taches adjacentes" contains the source code :

            K2.Synchronous = true;
            K2.ExpireActivity(K2.ActivityInstanceDestination.Activity.Name);

Anybody know why it is not working ? 


 

The ExpireActivty() method can only expire the current activity instance, not any other ones.  The fact that the method accepts a string parameter implies that it can be used to expire other activities; however no matter what the value of the string is that is passed in I believe it will expire the current activity that it resides in.  It is my understanding that this string parameter was left in for backwards compatibility purposed with previous version of K2.


In your case, if you want to expire Activity 1 & 3  from within "Synchroniser le circuit" you should use the GotoActivity() method; like:


    K2.GotoActivity("Some Activity Name");


The Goto Activity method will shutdown/expire all open activity instances within this process instance and then jump to the Activity that is sated within the GotoActivity().


Attached is a screen shot of how i might accomplish this in your scenario.  You'll notice that i created a new activity called 'Before Activity 5 and 6" which contains a single server event.  i put it belore the "Synchroniser le circuit" activity and moved the line logic that originally exicted from ""Synchroniser le circuit" to exit from this new activity.  This server event in the new activity does not do anything.  The purpose of this new activity is to function as a target for the GotoActivity method.  As such I would change the code in your "Fermer toutes les taches adjacentes" event to read as follows:


            K2.Synchronous = true;
            K2.GotoActivity('Before Activity 5 and 6");


Hope this helps.


16005i551EF61E2242C86F.jpg
Thank you Bob, Your solution works perfectly : )

Bob,


I ran into the same problem and this fixed it. 


Here is the problem.  I have two parallel infopath client events.  If one gets canceled; they are both canceled.  The problem is if I cancel one, the second one's InfoPath form is not cleaned up and remains in the form library.  I believe the dynamic file name is an activity field but I am not sure how to get it from a different activity.


Jason


Jason,


You may be able to do use something like the below code snippet.  I haven't tested it to thoroughly (and my test scenario had nothing to do with InfoPath) but in a quick test when executing this in a server event in a different activity than "Review Task" i was able to recover the value from the data field called "My Data Field".  Perhaps this will give you some ideas.


HTH.


Bob 


 


             string strOtherActivityName = "Review Task";
            string strOtherDataFieldName = "My Data Field";
            string strValue = "";


            foreach (ActivityInstance oActInst in K2.ProcessInstance.ActivityInstances)
            {
                if (oActInst.Activity.Name == strOtherActivityName)
                {
                    foreach (Slot s in oActInst.WorklistSlots)
                    {
                        strValue = s.DataFieldsostrOtherDataFieldName].Value.ToString();


                        K2.ProcessInstance.Logger.LogDebugMessage("**", "**** " + strOtherActivityName + "." + strOtherDataFieldName + ": " + strValue);


                    }
                    break;
                }
            }
             


 


Bob,


I will check this out.  Do you know off hand if the WorklistSlots will have the same data as ActivityInstanceDestination?  When I look at the Process Overview report the ip file name is on the ActivityInstanceDestination and not in the slot data.


Another thing is that my activities may be executed more than once (reject/resubmit).  As well each activity instance may have multiple slots.  So when looping over the WorklistSlots do you know off hand if it will loop over all of the destination instances that have ever occurred?  Note sure if I am making sense here.


Jason


Reply