Skip to main content

Sometimes it is necessary for a user to hand pick a collection of users to act as the recipient of an activity and client event.  Typically, the user's form has a list box which they can add users to via an AD search box.

The question then is, where do I place those names once the user has selected them and posted the form.  There are several options, but my favorite is via a SmartObject so that is what I will demonstrate here.

Keep in mind that you may want to cleanup these entries in the SmartObject via a filtered list delete method - documented here


1)  Create a Smartbox SmartObject that will house temporary destination lists. It will need the following properties
     a.  ID (autonumber)
     b.  ProcessInstanceID (number)
     c.  ActivityKey (text)  should contain the ActivityName + ProcessInstanceID
     d.  UserName or DestinationUser (text)

2)  Populate the SmartObject as the user's form is submitted with records for each destination user, for example
     ProcessInstanceID      ActivityKey               DestinationUser
     231                            SupportRequest231   Codi
     231                            SupportRequest231   Anthony
     231                            SupportRequest231   Bob


3)  Populate a Process.Datafield that will trigger the destination rule to compute to true


4)  Create a destination set which pulls in the DestinationUser from the Smartobject based on the current processid and activityname when it's destination rule computes to true as displayed here:


14654iA55ACA0317B1BE92.png

If this will be the only destination set for the activity, then step 3 wouldn't be necessary.  However, inviting users to create their own destination list, can end up with errors.  At least one of the destination sets assigned to an activity must contain at least one user.


So,  in your code, after writing the desired records to the SmartObject, go back to the process data and set a process datafield as a flag indicating that it is okay for this particular destination set to run.  In your code you would write something like:


 ProcessInstance.DataFielda"blSupportRequestCustomDestination"].value = true;
note: refer to http://k2underground.com/forums/ShowThread.aspx?PostID=19161#19161 for additional links and code

And within your destination set, define a rule that will only compute true when this field has been flagged.

When getting into these custom destinations, you can add some safety by adding one additional Destination set to each Activity which computes true if none of the other destination sets do.  This destination set can be assigned to your support group or the appropriate management role.

Just as an FYI, here is a screen shot of this SmartObject:
original.aspx


Please note and remember that although properties and multiple parameters are exposed as inputs when using a SmartObject GetList method to populate a destination set, that YOU MAY ONLY USE ONE PARAMETER as of HF2.01.

First, Great posts from you, some of the few how to's i've found.


Second, Can you explain the Name field in the Destination Sets screen. I got your example to work with infopath form backed by moss, but I could only do single users, and your example shows 3 users. The Wizard doesn't let me change the xpath that it gets.


Thanks


 


Hello,


I tried to implement the CustomDestination SmartObject, but I get the following error:


At least one element in the source array could not be cast down to the destination array type


Probably there is an error in my Destination Set and Rule:


See the following screenshots:


dset01.jpg


 and for the rule:


dset02.jpg


Routing is a DataField that contains: "Applications"


CustomDestinations.Get List.ActivityKey contains: "Applications"


CustomDestinations.Get List.ProcessInstanceID contains 28


So I guess that there must be some mistake with the ProcessInstanceID compare


Nicolas


I managed to get it to work.


My mistake was that I did the input parameter comparisons in the Destination Set Rule.


Filling in the vars in the SmartObject in the Destination Set properties did the trick.


I must say, this is great stuff. In K2 2003 I had something similar using XML fields. On activity level, I had to write custom code to loop trough my xml content, and so creating multiple dynamic destinations.


The method with the SmartObject is much easier as it can be completely done using the GUI of the Studio Designer.


I've discovered one bug though. After setting the input vars of the smartobject the first time. (using Object Explorer to select eg Process Instance), if you go back to the properties of the input vars, you can't browse with the Object Explorer to data fields, etc, only Environment and User browser is available.


But buttom line, this was/is a great exercise to get to know the benefits of a SmartObject.


Can you elaborate on step four please?

 I've attempted to create a destination set that pulls from a SmartObject, but each time it reaches this step of the process, the process ends up sitting in the "Running" state indefinitely. If I replace it with a static role, it works fine. I'm sure I must be doing something incorrectly, but I can't figure out where I'm going wrong.


I believe I have done everything as detailed in this example. However, when the process tries to get to the step where the dynamic destination users are being determined, the following error is being thrown:



Type 'SourceCode.SmartObjects.Client.SmartObjectNotFoundException' in assembly 'SourceCode.SmartObjects.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=16a2c5aaaa1b130d' is not marked as serializable.

 

Does anyone know what this means?

 

T.I.A.

~Robin

Reply