How to get to a destination set rule code (code behind)

  • 4 August 2008
  • 7 replies
  • 2 views

Badge +4

I have multiple destination sets that depends on a rule that is based on a smart object's property. 


My problem is that sometimes the smart object's property returns a null value and I don't know how to determin if my first variable is null in the destination set rule editor.


Is there a way to get to the code behind, or is there a way I can use the rule editor to determine if my first variable is null.  I tried SmartObject.Property = null, but that does not seem to work.


I was also under the impression that when you add multiple destination sets, there should be a checkbox saying first true or all true.  I do not get this, not sure if it should be there?


Any help would be appreciated.


7 replies

Badge +11

Once you have set a destination rule, you can get to the code behind by right-clicking the activity, select view code, then select destination rule.


I think you can use the rule editor to check for a null value by simply comparing your value to nothing.  That is, in the value to compare against, don't put anything.  The rule editor will then show something like 'MyProperty = [Empty Value]'.


 

Badge +4

Thanks David


I managed to get to the code behind the destination rule, but I can find the code I configured in the destination set rule. 


If I congure my destination rule set to myProperty = [Empty Value] (just to see where this configured value is stored), I can only find the text empty value in ServerContext.cs and in the .kprx file.  I am not sure where to change it and to what to change it to when I want to check for null or empty value.


I have tried to leave my comparison value as empty but the K2 studio reported an error saying I need to privide a comparision value.


 

Badge +11

blackpearl doesn't generate code.  The rule set will be resolved at runtime.  Don't edit ServerContext.kprx or any other file outside of the designer.


Here's another way to compare against an empty value:  Create a string environment variable called something like "TheEmptyValue" and don't give it an initial value.  Then in the destination set rule editor, compare against your TheEmptyValue environment variable.


Give that a try before writing custom code.

Badge +4

Thanks for idea David


 I tried the empty environment variable, but got a compile time error.  It seems like K2 studio only recognise environment variables when they do have values.


I then discovered that the empty environemtn variable equates to a value of: <empty>


So I compared my smart object property to <empty>, this compiled but resulted in to a runtime error.


Is there a way to ascertain which destination set was used in the end? 


My concern is that since I can't get to my destination set rule code, I can't change it, which means I have to write custom code and I can't re-use any of the designer generated code.


 To avoid this, I assigned my smart object property to a datafield with a default value.  In this scenario it worked, but this solution is not ideal.


 


 


 

Badge +11

Henk,


There is no problem using environment variables that do not have an initial value.  What was the compile error?


You can create destination rule code.  When I say blackpearl doesn't generate code, I mean it does not generate custom code in response to the data you enter in wizards.  You can however override the destination rule code by right-clicking on the activity | View Code | Destination Rule.  From there, right-click on the WF activity and select View Code.


Since you have given your SmartObject property a default value, you could use this in your destination rule.  If your property has the default value, use one destination set, otherwise use the property as the destination.

Badge +4

When I compare my smart object property to an environment varialbe that is empty my compilation errror is:


Error 1 Environment Library FieldPart used in a 'SourceCode.Workflow.Authoring.K2Field' object cannot be found in your Environment Library. Re-run the wizard and assign new values where necessary. G:ProjectsAccountingAccountingProcessesK2ProcessesASRSubmissions.kprx 1 1 K2Processes


If I then assign a value to the environment variable, the process compiles.


With regards to the smart object destination code, I did not imply Blackpearl does not generate code, I got to the destination rule code fine.


The problem is more than I can't get to the code for the rules which determine which destination set will be used.


I do not know how to give a smart object property, a default value (apart from doing it in the service object). 


So I assigned my smart object property to a process data field with a default value.  This is not an ideal solution for me, but it works.  :)


Thanks for all the help.

Badge +4

Hello Henk,


I can confirm that leaving an environment variable empty results in a compilation error.


In my case assigning an initial value of something and comparing it at runtimed helped as "empty" <> "predefined something value".


Thanks,


DD

Reply