Accessing Environment fields from server code

  • 19 March 2008
  • 3 replies
  • 1 view

Badge +9
Should be a no-brainer, but how do we get to Environment fields from server code?  Process fields are easy:  K2.ProcessInstance.DataFields, but I don't see an intuitive way to get to Environment fields - is there one?

3 replies

Badge +11

The environment library is a design-time construct.  At run time the values can be found in the string table.  Take a look at this link and see if this helps:


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

Badge +9
Thanks for the response, but what the technique described be similar to simply grabbing 'K2.StringTable' in a server code event? 
Badge +9

After a few quick tests, I can answer my own question here:  Yes, K2.StringTable goes against the fields you define in the Environment section of the K2 Object Browser.  Even though the parameter asks for an 'Index', you actually specify the name of the field you want to grab.  So if you define a miscellaneous field in your environment named 'Test', to get its value you'd use this code:


K2.StringTable[

"Test"]

Reply