Hello There,
I would like to find out if it is possible to create a workflow dynamically?
Â
Regards
Amarnath
Hello There,
I would like to find out if it is possible to create a workflow dynamically?
Â
Regards
Amarnath
Hello There,
I would like to find out if it is possible to create a workflow dynamically from code?
Can you elaborate on what you are trying to accomplish? Describe the situation?
Hello There,
Here is my requirement.
Is it possible to call a workflow multiple times.
The scenario is as follows:
I have to fetch some data from the database and for each row i have to send a notification to owner. The Owner has to approve in a selected time. If he does not reply, i have to escalate the approval.
Â
Is it possible to call a worflow multiple times from a main workflow.
Â
Any Help will be appreciated.
Â
Â
Regards
Amarnath
Is it possible to call a workflow multiple times from code?
Â
Regards
Amarnath
Yes, however it will create individual instances of that workflow. each one seperate. Is that what you are looking for?
you would just need to write some code that iterated through your source of items, and do a for each type operation. Here is some sample code that starts a new processes and sets some data fields
Â
using System;
using System.Collections.Generic;
using System.Text;
using SourceCode.Hosting.Client;
using SourceCode.Workflow.Client;
Â
namespace K2Samples
{
   class WorkflowAccessingSample
   {
       public void SetDataFieldsStartProcess()
       {
           // TODO: Replace these placeholder values with values for your environment
           string _serverName = "blackpearl";
           string _user = "K2Student";
           string _domain = "DENALLIX";
           string _password = "K2pass!";
           string _processName = "K2WorkflowProject1Process1";
           string _name = "Total Cost";
           string _amount = "100";
           string _processFolio = "Project 1 Process 1";
Â
           SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder connectionString =
               new SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder();
Â
           connectionString.Authenticate = true;
           connectionString.Host = "localhost";
           connectionString.Integrated = true;
           connectionString.IsPrimaryLogin = true;
           connectionString.Port = 5252;
           connectionString.UserID = _user;
           connectionString.WindowsDomain = _domain;
           connectionString.Password = _password;
           connectionString.SecurityLabelName = "K2"; //the default label
Â
           Connection connection = new Connection();
Â
           try
           {
               //open connection to K2 server
               connection.Open(_serverName, connectionString.ToString());
Â
               //create process instance
               ProcessInstance processInstance = connection.CreateProcessInstance(_processName);
Â
               //populate data fields
               processInstance.DataFieldso"Name"].Value = _name;
               processInstance.DataFieldsÂ"Amount"].Value = _amount;
Â
               //set process folio
               processInstance.Folio = _processFolio + System.DateTime.Today.ToString();
Â
               //start the process
               connection.StartProcessInstance(processInstance, false);
Â
               Console.WriteLine("Name: " + processInstance.DataFieldsD"Name"].Value);
               Console.WriteLine("Amount: " + processInstance.DataFields "Amount"].Value);
               Console.WriteLine("Folio :" + processInstance.Folio.ToString());
               Console.WriteLine("ID: " + processInstance.ID.ToString());
               Console.ReadLine();
            }
Â
           catch (Exception ex)
           {
               Console.WriteLine(ex.Message);
               Console.ReadLine();
           }
Â
           finally
           {
               // close the connection
               connection.Close();
           }
       }
   }
}
Yes Chris
This is what I am looking for.
So I can have just one workflow and i can create multiple instances of it.
Thank You
Regards
Amarnath
You bet
Hello Chris,
I have a doubt regarding this method.
If IÂ call multiple instances of a workflow from a parent workflow and make is synchronous so that the parent has to wait till it hears from all the child instances, how would i keep track if all the instances have responded or not.
Also, how would the child instances behave? Are they synchronous or asynchronous.
Â
Â
Regards
Amarnath
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.