WorkflowGen.com | Knowledge Base | Documentation | Downloads | Support | RSS

Entries from December 1, 2007 - January 1, 2008

How can I make a drop down list required while not providing a pre-selected default value?

Posted on Sunday, December 30, 2007 at 22:36 by Registered CommenterWFG Team in | CommentsPost a Comment

When adding a drop down list control to a web form and making it required using WorkflowGen's FORM_FIELDS_REQUIRED parameter, one of the items in the list will become the pre-selected default value, which may defeat the purpose of the "required" setting (often we want to force the end user to select a value, not just assume that a pre-selected default is valid).

For example in making a list named DropDownListCities required where the list includes only the elements "New York", "Montreal", and "Paris", one of these items will become the default value and therefore submitting the form will pick this value (one of the cities), bypassing the need to force the user to think of about the selection.

Solution:
Add a list item (as the "selected" default) with the Text "Please select" and the Value of " " (one space only).  WorkflowGen will detect this as an empty value and submitting the form with this value will trigger the standard required field alert message, without programming.  This will provide a true required field effect with a drop down list without a default value pre-selected.

If the DropDownList control is bound to a database query, a simple tip to add an empty default value without programming is to alter your SQL query by prefixing it with the statement:

  SELECT 'Please select',' '
  UNION ALL
  [...your SQL SELECT statement here...]

This will insert a blank default value at the top of the drop down list.

How do I make checkboxes required?

Posted on Sunday, December 23, 2007 at 18:03 by Registered CommenterWFG Team in | CommentsPost a Comment

Checkboxes cannot be managed by the FORM_FIELDS_REQUIRED control in WorkflowGen since by definition a checkbox is optional.   If you need to have one or more checkboxes on your webform that must be selected ("required") before the user can submit the form, you can validate this rule by using the JavaScript below.  The JavaScript can be added to a CustomFieldValidator in your webform.  This CustomFieldValidator would use the ValidationGroup "WFGENPage" as its reference and call the validation JavaScript (e.g.: ClientValidationFunction="ValidateCheckBox").

Rule
The group of checkboxes must have an ID that share the same prefix
(e.g. REQUIRED_CHECKBOX_1, REQUIRED_CHECKBOX_2, etc)


1. Edit the Checkbox Webform Control(s):

<asp:CheckBox ID="REQUIRED_CHECKBOX_1" runat="server" Text="Option 1" />
<asp:CheckBox ID="REQUIRED_CHECKBOX_2" runat="server" Text="Option 2" />
etc...

2. Add a Webform CustomFieldValidator:

<asp:CustomValidator ID="cfv" runat="server" ErrorMessage="The checkbox group is required." Display="None" Enabled="True" SetFocusOnError="True" ValidationGroup="WFGENPage" ClientValidationFunction="ValidateCheckBox"></asp:CustomValidator>

3. Add a JavaScript:

function ValidateCheckBox(source, arguments)
{
    var ValidateResult = true;
   
    // call CheckAll to validate a specific checkbox group
    //(e.g.: "REQUIRED_CHECKBOX_x" where "x" is the unique part of the ID)
    ValidateResult = CheckAll("REQUIRED_CHECKBOX_");
   
    arguments.IsValid = ValidateResult; 
}

function CheckAll(MyPrefix)
{
    var retval = false;
   
    if (MyPrefix != "")
    {
        var elem = document.getElementById('form1').elements;
       
        // validate if one or more checkboxes are checked
        for (var i = 0; i < elem.length; i++)
        {
              if (elem[i].name.length >= MyPrefix.length)
              {
                    if (elem[i].name.substring(0, MyPrefix.length) == MyPrefix)
                    {  
                        if (document.getElementById(elem[i].name).checked == true)
                        {
                            retval = true;
                            return retval;
                        }
                    }
              }
        }
       
        // make borders red if no checkboxes in the group are checked
        if (retval == false)
        {
            for (var i = 0; i < elem.length; i++)
            {
                  if (elem[i].name.length >= MyPrefix.length)
                  {
                        if (elem[i].name.substring(0, MyPrefix.length) == MyPrefix)
                        {
                            document.getElementById(elem[i].name).style.backgroundColor = "#FF0000";
                        }
                  }
            }
        }
    }
    return retval;
}


Advanced Exercise
You can use this sample as a starting point to create a parameter-based function that makes checkboxes required based on a comma-delimited list similar in concept to FORM_FIELDS_REQUIRED.  Post your ideas here or on our client help desk!

What is the value contained in the macro <WF_ACTIVITY_INST_LIMIT_DATETIME>?

Posted on Sunday, December 16, 2007 at 16:42 by Registered CommenterWFG Team in | CommentsPost a Comment

Question
What is the value contained in the <WF_ACTIVITY_INST_LIMIT_DATETIME> macro? Is it the lead time value (ie: 90 days) of the action or is it the actual date that WFG calculates as the lead time (e.g. 90 days following the action is started/assigned)?

Answer
The latter: it is the calculated end-date (e.g. 90 days into the future), and is cast as a date/time value.

How do I create a "Save as Draft" functionality to my webform?

Posted on Sunday, December 9, 2007 at 14:31 by Registered CommenterWFG Team in | Comments1 Comment

On the community site, there is a Helpdesk webform process and some samples available for download that demonstrate the 'Save as draft' functionality.

To download the Helpdesk webform process template, click here (C# sample only).

To download the WebForm samples, click here for the Samples pack.  Samples 3 and 5 demonstrate the "Save as draft" functionality.

In summary, you need the following to implement the "Save as draft" functionality:

    • A webform button labelled as a “Save as draft”
    • A process data to hold the value of the save as draft flag 
    • A loop transition with a condition to check the process data (flag) value.

What is the difference between a process and a sub process?

Posted on Sunday, December 2, 2007 at 16:41 by Registered CommenterWFG Team in | CommentsPost a Comment
The only difference is that a sub process can be called from a another process or a third-party application.