Skip to main content

Hi,


 I am wanting to create dynamic escalations. I have read a few posts on this already, but can't quite see how I am going to achieve this.


What have I done so far and what setup do I have?

I am using winforms (C#) with Blackpearl.

I have managed to get a workflow started (using smartobjects) and moved on one step depending on the result of a another Windows form.

I have created 4 fields at the process data level (EscalationDays, EscalationHours, EscalationMinutes and EscalationSeconds). As I see it, these fields are unique for every worklist that is created and in the absence (or so I believe) of any higher level fields, decided to set these fields from another static source (eg smartobject) everytime a worklist is created and link the escalation day, hour, minute and second fields to these newly populated fields.


My questions are:


Is this the best way to achieve this?


Could you give me any pointers from here, code samples would be great.


I have doubts that I'm doing this correctly. I've heard of something called the 'Environment Library' which sounds more like it, however, I don't know where this is, or how to interract with it. 


 Many thanks,


 Kevin.

Kevin,


Not sure if you question is regards to dynamic escalations as it is more do to with setting up a configuration.  If your intent is to have the EscalationDays, EscalationHours, EscalationMinutes and EscalationSeconds as a configuration to your process that set by an admin (similar to app.config or web.config) then I would be using the Environment Library.  You can access the Environment Library in the K2 workspace in the Management Consule.  Think of the environment library as a class definition of re-usable configurations that you can use across processes.  You can set the default values for EscalationDays, EscalationHours, EscalationMinutes and EscalationSeconds in the environment library.


In you escalation in your process, you can select the EscalationDays, EscalationHours, EscalationMinutes and EscalationSeconds fields from the environment library.


Then after you deploy your process, if you want to change the EscalationDays, EscalationHours, EscalationMinutes and EscalationSeconds values, again go to the management consule in the K2 workspace but drill down in the process.  You will see a node called StringTable.  This is where you change the values that are being used by the actual running instances.


Jason


Hi Jason,


Thank you for your response, that does sound a bit more like it, however, maybe I've misunderstood or done something wrong. Let me tell you what I have done:


Within the 'Management Console' in the workspace, I have drilled down thus 'Environment Library - Templates - Default Template - Development - Environment Fields'. Here I have added my 4 escalation fields. The fields do now appear within the Object Browser from Visual Studio within 'Fields' in the 'Environment (Development)' section.


I now bring up the wizard for the Escalation and on the 'Edit Escalation' screen I click the elipses and browse to the fields using the Context Browser and drag the required fields across. Here's where my problem starts, this process is being refused (mouse pointer stays as unavailable). Clicking 'Add' fails to take the field across also. I am running with Blackpearl SP 1.


Another question I would have is: is it possible to interact with these environment variables and alter them through a windows form, rather than giving users access to the management console?


 Many thanks,


 Kevin.


:-)  Yes I have seen that issue where the add/drag and drop does not work.  Drove me a little crazy.  I was getting on Hotfix 2; I have not seen it again yet on SP1.  One time I went as far as closing studio and rebooting and then it would worked.


Agree - giving business users access to the management consule can be a little bit scray.  I would have to do a little research but I believe the workspace itself is built on the K2 API so it should be possible.  The StringTable values are pretty accessible in the K2 database but I would not recommend writing your own code to edit those values in the database.  I know K2 would say not to do that.  I would have to do some investigation...


Direct K2 database access is definately not a supported action.  japergis is correct in that the K2 Workspace is built upon the commonly available K2 APIs.  This are of K2 Workspace utilized the SourceCode.Workflow.Management.dll.  There is API access to get and set environment (called String Tables within this API).


Below are some examples that I quickly worked up with this APIto retrieve all entries and to set a specific value.  There is probably room for improvement as this was done in short order but it should provide some guidance on how this can be accomplished. 


Please note that when programatically accessing the Workflow.Management API the connection must be made under the credentials of a K2 Admin (as set in workspace) otherwise it will not work (K2 securitiy is enforced even through the API, not simply the application level).  While not shown in the below example, this is typically masked from the end user by programmatically passing in specific user credentials when instantiating the WorkflowManagementServer object.



        private void GetEnvironmentVariables(string strServerName, uint nPortNumber, string strEnvrionment)
        {
            SourceCode.Workflow.Management.WorkflowManagementServer oSrv = new SourceCode.Workflow.Management.WorkflowManagementServer(strServerName, nPortNumber);
            oSrv.Open();
            SourceCode.Workflow.Management.StringTable oST = oSrv.GetStringTable(strEnvrionment);
            for (int x = 0; x < oST.Count; x++)
            {
                string strName = oST.Name;
                string strValue = oST.Value;


                // do something with these like bind to UI
            }
            oSrv.Connection.Close();
        }


        private bool SetEnvironmentVariables(string strServerName, uint nPortNumber, string strEnvironment, string strFieldName, string strFieldValue)
        {
            bool bSaved = false;
            SourceCode.Workflow.Management.WorkflowManagementServer oSrv = new SourceCode.Workflow.Management.WorkflowManagementServer(strServerName, nPortNumber);
            oSrv.Open();
            try
            {
                bSaved = oSrv.EditStringTableEntry(strEnvironment, strFieldName, strFieldName, strFieldValue);
            }
            catch { }
            oSrv.Connection.Close();
            return bSaved;
        }


Reply