I was trying to create dynamic destination rule from a sharepoint web part. But I could not get any result. Here is my code.
protected void btnSubmit_Click(object sender, EventArgs e)
   {
       SourceCode.Workflow.Client.Connection conn = null;
       try
       {
           conn = new SourceCode.Workflow.Client.Connection();
           conn.Open("DLX");
           SourceCode.Workflow.Client.ProcessInstance pi = conn.CreateProcessInstance("SampleApprovalSampleApprovalProcess");
           strUsers = ppApprovers.CommaSeparatedAccounts.ToString();
           string AllUsers = string.Empty;
           string>] split = strUsers.Split(',');
           foreach (string item in split)
           {
               AllUsers += item.Replace(@"", @""") + ",";
           }
           AllUsers = AllUsers.Remove(AllUsers.Length - 1, 1);
           pi.XmlFields,"subject"].Value = txtTitle.Text;
           pi.XmlFieldsl"message"].Value = txtDescription.Text;
          Â
           //Response.Write(strUsers);
           AssignReviewers(pi, AllUsers);
           conn.StartProcessInstance(pi);
       }
       catch (Exception ex)
       {
           Response.Write(ex.Message);
       }
   }
Â
protected void AssignReviewers(ProcessInstance pins, string listOfUsers)
   {
       try
       {
                   XmlDocument doc = new XmlDocument();
                   XmlElement root = null;
                   XmlNode userNode = null;
                  Â
                   root = doc.CreateElement("UserList");
                   doc.AppendChild(root);
                  Â
                   foreach (string user in listOfUsers.Split(','))
                   {
                       userNode = doc.CreateElement("Users");
                       userNode.InnerText = user;
                       root.AppendChild(userNode);
                   }
                  // Response.Write(doc.OuterXml.ToString());
                   //item.ProcessInstance.XmlFieldsÂ0].Value = doc.OuterXml;
                   pins.XmlFields)"approvers"].Value = doc.OuterXml;
       }
       catch (Exception ex)
       {
           Response.Write(ex.Message);
       }
      Â
      Â
   }
Please help me if you can.