Getting the Destination User who finished the event activity

  • 7 November 2007
  • 8 replies
  • 2 views

Badge +8

In BlackPearl I am running into a issue around getting the user information for the person who finished an InfoPath client event.  I have an InfoPath event that gets blasted out to a bunch of people via a Role and then I want the first person who approves will complete the event.  That works.


Now I want to find the user who actually did this.  Yes I could capture that in the InfoPath form, but my goal is to keep InfoPath dumb and thin at all cost.  So, I tried to add an event handler after the InfoPath client event handler.  Added code to go to the Activity Instance and loop over all of the destination users.  The destinations collection is one (which is good) but when I reference the User property I get a null error.


Thoughts?


8 replies

Badge +8

Let me expand on this in a different way.  I have an InfoPath client event on an activity.  I want to email the destination user prior to starting the InfoPath client event.  I have set the destination user using a field that has the active directory name for the user in the InfoPath form.  Nothing more.


All I want to do is get the email address for the destination user.  I should be able to do something like K2.ActivityInstanceDestination.User.Email but the User object is null.  What gives?  Is it only not null in the actual client event?  I know the destination user is there because the worklistitem for the user is being created.  Personally I do not want to have to start adding a bunch of custom code into the InfoPath client event...

Badge +11

Hi Jason,


Just a thought, could be wrong...


Have you tried planning your Activity containing the InfoPath Client Event per Destination?  Or is it set to 'Plan just once'?


Have a look at: http://k2underground.com/forums/post/19518.aspx


HTH,


Ockert

Badge +8

Ockert,


I think this resolved several problems I was having as well with email events.  I would get an error if I would try to email the destination users with Plan Just Once selected.


I want to confirm some things here.


I have this set up with a Role set as the destination user.  I then have the destination rule options set to Plan per destination >> All at once.  I have Create a slot for each destination selected.  And I have Resolve all roles to users selected.


I am trying to use Roles and assign them as destination users (best practice).  So I have the situation where I have an activity with three people (they are in the Role).  First person that completes the InfoPath form completes the activity.  In the K2 2003 days I believe that would have created three infopath forms in the document library for each activity instance (I am drawing a blank).  In my case, I do not want that to happen, I one form.  When reading the code in the InfoPath client event it lead me to believe that it would do this.


Will the above configuration do what I want it to do?


Thanks,
Jason

Badge +11

Hi Jason,


Unfortunately, I think you've stumbled across a confirmed bug which *should* be resolved in the next release i.e. Resolving Roles to users and only getting 1 slot to work with.


Sorry for the inconvenience - we're looking into it,


Ockert

Badge +8

Ockert,


Yeah the behavior is strange and had stumped both Codi and I. 


Here is the thing, for the business process I have I like the fact that only one XML file is created in the document library.  When I have a business process that is broadcasted to a group of users, lets say 3, and the first one who completes the InfoPath form finishes the activity all I want to see is one xml file in the form library.  They are all working on the same shared instance of the file.  


I understand the original intention of creating seperate XML files for each activity instances for each slot but that is not needed.  So if you change this to create activity instances for user in the Role, I believe that is not going to solve my problem.  I think my only solution would be to go in the IP generated code and comment out the code that creates XML files for each activity instance, etc.  I really do not want to do that.


Thanks
Jason

Badge +7

Jason,


 


I want to do exactly what you are doing so I investigated server event code after to infopath form event, see


http://k2underground.com/forums/thread/22058.aspx


for my question.


I'm just not sure about what I should be coding in the API


Martin

Badge +9

Hi Martin.


I assume you are asking in relation to this post:  http://k2underground.com/forums/thread/22058.aspx


I just replied to that one a few minutes ago with some details in it around this question (i.e. how to retrieve the destination user from within an activity). 


For completeness of this thread, below is what I posted in that other thread:



You mention that you are interested in doing this for a specific destination.  If you are using the default "Plan just once" destination, then this will not have any user context.  I think you will need to change the Destination to "Plan per Destination - all at once" in the Activity Destination Rule - Advanced options in order for you to have user context at this level, which you should then be able to recover with code like:


   string strDestUser = K2.ActivityInstanceDestination.User.FQN;


HTH.

Badge +8

Sorry for not getting back sooner.


Bob is right.  However in my situation I had tons if InfoPath client events and I did not want to have to customize every one of them.  So what I recall I did was change the destination rule to be plan all at once which resolved the issue I was having above.  If you plan just once the activityinstancedetiation.user will always be null.  Then I created a class to do what I needed and I called the code in a .net code event handler after each InfoPath client event within the same activity.  Again the only reason why I did this was because I had 20 or so client events and I did not have to make this manual change over and over again...


Jason

Reply