K2 objects in K2 code modules

  • 24 October 2007
  • 3 replies
  • 1 view

Badge +4
We have several code modules in K2 containing various methods. Each method is overloaded to take either a ServerEventContext or a ClientEventContext argument. So basically all our code is duplicated. Is there not a way to pass a general EventContext so we can remove this overloading/duplication?

3 replies

Badge +11

Sorry, none that I know of.


Regards,


Ockert

Badge +9

I agree with Ockert as I'm not aware of any either.


However, what is it that you need from these different objects?  If it is just the ProcessInstance and/or ActivityInstance objects why not just create one method in your Code Module and pass in the two objects explicity as parameters, instead of the entire K2 context object?  It requires just slight modifications to your calling code, but greatly simplifies your Code Modules.

Badge +13

If you define your parameter as Object then you can pass in "K2", just be sure the properties/methods you are executing exists in all the variations you are passing in.

You'll lose intellisense.

Let me know if this works:   Parameter you pass in is ByvVal K2 as Object.

You are sending some generic email that uses K2.StringTable and calls from ClientEventContext and ServerEventContext.

You can fake it to one of the EventContext and still get intellisense/early binding compile. 

        Dim objK2 As ServerEventContext
        objK2 = DirectCast(K2,ServerEventContext)


 

Reply