IT:AD:K2:Development:HowTos:Create a Client Event

  • Select Default Client Event
  • Screen:

On the application side

using(var connection = new Connection())
        {
            connection.Open(k2Server);
 
            var workItem = connection.OpenWorklistItem(serialNumber);
            var processInstance = workItem.ProcessInstance;
 
            foreach (var variable in variables)
            {
                string variableValue = processInstance.DataFields[variable].Value.ToString();
                variableValues.Add(variable, variableValue);
            }
 
            return variableValues;
        }

But how is the user going to know about it?

  • He's going to be sent an email, with customized Text title
  • Next Screen:
    • Send a Standar or Customized Notification to the Destination Users=true
    • Customize the Notification Message=true..
      • Etc…
      • Note: you drag users in the from the pop-out panle on the right…
      • Notice the email text that has the LINK back to the website page (plus SN)
      • Notice that the text is rather generic. To spice it up – by merging in vars – expand the tab to the right.
        • Also, note there is a number of built in logical functions in K2 which can be used to put logic-specific text in the email. For example if you have an escalation loop which means the task is entered into 2 or 3 times you can build in logic to display certain text depending on what part of the escalation process is currently active.

Once the Url is defined, and an Email event to trigger that async navigation event, we are back to normal Event issues, such as what course of Actions to take after the Event:

In the example below, two things could have happened after the end user presses the submit button on the web form (which will contact and update the K2 database).

These will setup the Connector Lines coming out of the Event.

In Configure Actions Screen, Add Submit and Cancel. Type = Finish, and Generate corresponding Outcomes=true.

Note that we've given them arbitrary names – in this case Submit, or Cancel (but they easily could have been Moo and Schmoo if you wanted).

An Action Result is effectively K2's way of determining what has occured from the client page (normally this would typically be a custom ASP.NET web page sitting in an application which hooks into K2 for workflow purposes). In the above example this is either “Submit” or “Cancel”. An example of how you would set these values from an ASP.NET page is as follows (basically the string “action” is set to either “Submit” or “Cancel”):

  public void ProgressWorkflow(string k2Server, string serialNumber, string action)
      {
          using (var connection = new Connection())
          {
              connection.Open(k2Server);
              var workItem = connection.OpenWorklistItem(serialNumber);
              var workItemAction = workItem.Actions[action];
              workItemAction.Execute();
          }
      }

Once the ActionResults from the client event are received they are then mapped to “Outcomes” which is what is then used to determine where K2 goes in the next process step. Note, many Action Results can map to one Outcome. By ticking the box “Generate corresponding lines…” the lines from the activity will appear automatically which can then be joined to the next step in the process.

Note: On the other side of things, the dev in charge of the website is going to use the QueryString param to find the record in the mutual db, pull it up, display it, and when the Submit button is pressed, call back to K2 to say that the event is processed. More on that in the ToDo section.

  • /home/skysigal/public_html/data/pages/it/ad/k2/howto/create_a_client_event/to_sent_a_user_to_a_website.txt
  • Last modified: 2023/11/04 02:23
  • by 127.0.0.1