www.skelta.com
Home      Members   Calendar   Who's On

Welcome Guest ( Login | Register )
      

Home » BPM.NET 2007/Sharepoint Accelerator 2007 » BPM.NET 2007/Sharepoint Accelerator 2007 » Workflow Execution » Checklist activity: How to answer to...


Checklist activity: How to answer to...Expand / Collapse
Author
Message
Posted Wednesday, December 12, 2007
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Wednesday, March 05, 2008
Posts: 80, Visits: 277
HI,

I have tried to answer check-list activity questions in run-time trough api, but I haven't been able to successfully achieve this.

In order to "submit", or end this activity I need to answer all the mandatory questions, how can I do this?

Let's say that in run time I want to check next to skelta what are the questions to present to my users, which are mandatory and then answer to them.

What's the best practise to do this?

Thanks for your time.

Best regards,

Rui
Post #164
Posted Thursday, December 13, 2007
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Thursday, April 10, 2008
Posts: 23, Visits: 38
Hi Rui,

The questions in a checklist can be accessed as below.

Workflow.NET.PropertyTypes.PropertyCheckList _PropertyCheckList;
_PropertyCheckList = CurrentHWSActivity.CurrentActivity.Properties["Questions"];

You can use a foreach to loop through the questions as in the following example

foreach (PropertyCheckList.Question q in ((PropertyCheckList)_PropertyCheckList.PropertyHandler).Questions.Values)

Whether a question is mandatory or not can be checked with the property "mandatory" of the question

q.mandatory in the above example

Hope this helps.
- RS

Post #171
Posted Thursday, December 13, 2007
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: Wednesday, April 30, 2008
Posts: 5, Visits: 237
Hi Rui,

           I am not sure about  answering questions through API. But I would like to share the knowledge about checklist with you. Hope it is of any use.

Basically Check list can be created in the following procedure:
1. Click on the Questions Property.
2. Enter the number of questions you require and click on Add New
3. Complete the following entries:
• Type your question in the first text box
• Select the UI you wish to be displayed to the actor
• Enter the number of choices for the question
•  Check whether mandatory field is checked, if it is  the actor will be prompted to enter value during action
• Red Exclamatory mark denotes  that this question will be the decision maker for the checklist
• Enter the options for the questions, default value ( if any) .You must also specify the values that the answer will take internally in the Values text box
The actor will be able to see the questions in the same UI in Work item list and answer them.


Thanks & Regards,
Sameena

Post #174
Posted Friday, December 14, 2007
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Wednesday, March 05, 2008
Posts: 80, Visits: 277
Hi there,

First of all, thank you for all the answers provided.

However, I might have not explained myself on what I want to know.

Right now I have a web application that displays my check-list activities questions, what I want is a way of providing the answers to those questions.

For example, let's say that in my application I have question:
how old are you? that maps this answer to a variable, let's say it's called "age"

This question is the only one and it's mandatory.


I am able to move forward (submit method) when I don't have mandatory fields, or to change the variables myself (set it's value and then use the saveVariables method).

Now, using the API, how can I answer this question so that when I use the "submit" method it will allow me to continue with the execution of my workflow?

Thanks once again for your time.

Best regards,

Rui
Post #183
Posted Friday, December 14, 2007
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Saturday, April 26, 2008
Posts: 128, Visits: 422

There are two approaches for achieving this functionality:

1)     Just doing and submit for work item, this may cause issues in reporting as we are not persisting the questions and answers for the checklist.

2)     Submit the work item along with the questions and answers build in xml format.

//I'am assuming you have the required information to create the WorkItem object.
//Required information : Repository (Application name), Workflow name, WorkItem Id
//I have two questions which are mandatory.
//1) How old are you ?
               //Question type is text box and the mapped to variable is CheckListAnswer
//2) Sex !
             
//Question type is dropdown and is a completion maker. The values for dropdown is Male,Female and i have conditional routing based on these outputs.

Reference dlls : Workflow.NET.NET2.dll & Skelta.HWS.dll

using System;
using System.Xml;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Workflow.NET;
using Workflow.NET.PropertyTypes;
using Workflow.NET.Engine;
using Workflow.NET.Interfaces;
using Workflow.NET.Storage;
using Skelta.Core;
using Skelta.HWS;

Approach 1:

WorkItem _WorkItem = new WorkItem(new WorkflowObject("WorkflowName", new ApplicationObject("ApplicationName")), new Guid("758EAF52-D936-469F-A03E-E34FB8A2AEC3"));
_WorkItem.Submit(
"WebWorkList", "Male", "", "", null);

Approach 2:

WorkItem _WorkItem = new WorkItem(new WorkflowObject("WorkflowName", new ApplicationObject("ApplicationName")), new Guid("758EAF52-D936-469F-A03E-E34FB8A2AEC3"));

            HWSActivity _HWSActivity = _WorkItem.HWSActivity;
            Workflow.NET.Engine.Context _WorkflowContext = _WorkItem.CurrentContext;
            Property _PropertyCheckList = _HWSActivity.CurrentActivity.Properties["Questions"];

            string result = "";
            string decisionvalue = "";
            MemoryStream objMemoryStream = new MemoryStream();
            StreamWriter objStreamWriter = new StreamWriter(objMemoryStream);

            try
            {

                if (_PropertyCheckList.PropertyHandler != null)
                {

                    System.Xml.XmlTextWriter objXmlTextWriter = new System.Xml.XmlTextWriter(objStreamWriter);
                    objXmlTextWriter.WriteStartElement("checklist");
                    objXmlTextWriter.WriteStartElement("respondinguser");

                    objXmlTextWriter.WriteAttributeString("submittedby", _WorkItem.Actor.Resource.Properties.Name.Value.ToString());
                    objXmlTextWriter.WriteAttributeString("submittedbyidentifier", _WorkItem.Actor.Resource.Properties.Identifier.Value.ToString());
                    objXmlTextWriter.WriteEndElement();
                    int StyleCount = 2;
                    int dropDownCounter = 0, textBoxCounter = 0, radioButtonCounter = 0, checkBoxCounter = 0, memoCounter = 0;
                    foreach (PropertyCheckList.Question q in ((PropertyCheckList)_PropertyCheckList.PropertyHandler).Questions.Values)
                    {
                        string options = "";
                        if (q.Name.Length < 15)
                        {
                            objXmlTextWriter.WriteStartElement("question");
                            objXmlTextWriter.WriteAttributeString("name", q.displaytext);
                            objXmlTextWriter.WriteAttributeString("identifier", q.Name);
                            objXmlTextWriter.WriteAttributeString("questiontype", q.questiontype);
                            switch (q.questiontype)
                            {
                                case PropertyCheckList.QuestionTypes.DropDown:
                                    dropDownCounter++;
                                    objXmlTextWriter.WriteAttributeString("questiontypecount", q.questiontype + dropDownCounter);
                                    break;
                                case PropertyCheckList.QuestionTypes.Textbox:
                                    textBoxCounter++;
                                    objXmlTextWriter.WriteAttributeString("questiontypecount", q.questiontype + textBoxCounter);
                                    break;
                                case PropertyCheckList.QuestionTypes.RadioButtons:
                                    radioButtonCounter++;
                                    objXmlTextWriter.WriteAttributeString("questiontypecount", q.questiontype + radioButtonCounter);
                                    break;
                                case PropertyCheckList.QuestionTypes.Checkbox:
                                    checkBoxCounter++;
                                    objXmlTextWriter.WriteAttributeString("questiontypecount", q.questiontype + checkBoxCounter);
                                    break;
                                case PropertyCheckList.QuestionTypes.Memo:
                                    memoCounter++;
                                    objXmlTextWriter.WriteAttributeString("questiontypecount", q.questiontype + memoCounter);
                                    break;
                            }
                            objXmlTextWriter.WriteAttributeString("defaultvalue", q.defaultvalue);
                            objXmlTextWriter.WriteAttributeString("decisionmaker", q.decisionmaker);
                            objXmlTextWriter.WriteAttributeString("optioncount", q.optioncount);
                            objXmlTextWriter.WriteAttributeString("includeinxml", q.includeinxml);
                            objXmlTextWriter.WriteAttributeString("mandatory", q.mandatory);
                            foreach (PropertyCheckList.Option o in q.Options.Values)
                            {
                                objXmlTextWriter.WriteStartElement("option");
                                objXmlTextWriter.WriteAttributeString("value", o.OptionValue);
                                objXmlTextWriter.WriteString(o.Text);
                                objXmlTextWriter.WriteEndElement();
                                if (options != "")
                                    options += ",";
                                options += o.OptionValue;
                            }
                            if (q.decisionmaker == "yes")
                            {
                                decisionvalue = "Male";
                            }
                           
                            //Harcoding the output values based on question type
                            string qAnswer = "";
                            if(q.questiontype == "textbox")
                                qAnswer = "21";
                            else
                                qAnswer = "Male";

                            objXmlTextWriter.WriteStartElement("answer");
                            objXmlTextWriter.WriteString(qAnswer);
                            objXmlTextWriter.WriteEndElement();
                            objXmlTextWriter.WriteEndElement();
                            if (StyleCount == 1)
                                StyleCount = 2;
                            else
                                StyleCount = 1;

                            //Code to store the output  to workflow variables
                            if (q.maptovariable != null && q.maptovariable.ToLowerInvariant() != "none" && q.maptovariable.Trim() != "")
                            {
                                string[] tempmapvar = q.maptovariable.Split('.');
                                if (_WorkflowContext.Variables.Contains(tempmapvar[1]))
                                {
                                    _WorkflowContext.Variables[tempmapvar[1]].Value = qAnswer;
                                    _WorkflowContext.SaveVariables();
                                }
                            }
                        }
                    }


                    objXmlTextWriter.WriteEndElement();
                    objXmlTextWriter.Indentation = 4;
                    objXmlTextWriter.Formatting = Formatting.Indented;
                    objStreamWriter.Flush();
                    objMemoryStream.Flush();
                    objMemoryStream.Seek(0, SeekOrigin.Begin);
                    StreamReader sr1 = new StreamReader(objMemoryStream);
                    result = sr1.ReadToEnd();
                    objMemoryStream.Close();
                }
                _WorkItem.Submit("WebWorkList", decisionvalue, result, "", null);               
            }
            catch (Exception e)
            {
                throw new System.Exception("Error while submitting check list " + e.Message);
            }



Moderator
Post #186
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
-
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.

All times are GMT -5:00, Time now is 11:12pm

 
Execution: 0.156.9 queries.Compression Enabled.

Copyright © 2002 - 2007 Skelta Software. All rights reserved. Tel: 1 (703) 229-6732 | Email:sales@skelta.com
Skelta - A BPM Workflow Software Company