SmartObject server connection string within a code activity?


Badge +8

I have a scenario where a user could submit a request on behalf of one or more other users.  I'm using an XML field to store the employee IDs (from another system), then using SmartObjects to get various properties of each employee.


I've got a code activity to do some processing on these values when the workflow kicks off.  To load the SmartObject, I'm currently building the connection string manually, including assigning the name of the server.  This isn't ideal in our environment, as the name of the SmartObject server will change in production.  I was hoping I would be able to get to a "more dynamic" connection string through the K2.Configuration object, but I haven't been able to find anything useful thus far.


Can I get at a SmartObject connection string that is "more aware" of the current environment?


I'm using BlackPearl 4.6.


2 replies

Badge +11

Look at the Enviornment tab of your context browser in VS or K2 Studio.  Each of those items represnts a design-time enviornment variable.  There will be a variable called "SmartObject Server" that contains the connection string.  You could obtain the value in code at runtime like this:



string conn = K2.StringTable["SmartObject Server"];



Make sure to always close the connection in a using or try/catch/finally block.


Badge +8

Awesome, thanks!

Reply