Workflow scheme

Scriptable Workflows have a dedicated screen area for the workflow user interface design and four areas for the script design.

Form Designer

The Form designer is built for designing the workflow user interface displayed on the MFP. It serves as a visual aid in composing the workflow UI. It features both a Design view (graphics) and a Code view (scripting for event handlers of the form controls).

If you start out from Design view, you have to add the required control elements available on the left of the designer window.

These control elements, from top to bottom, stand for:

  • Label
  • Textbox
  • Passwordbox
  • Combobox
  • Dropdownlist
  • Checkbox
  • Button

Simply drag-and-drop the selected control type to the desired slot in the form designer window. When in place, the controls can still be rearranged via drag-and-drop. The control element in place appears in the following format:

<Label for [textbox_1]> textbox_1

You can edit the control label by double clicking it. Click outside the editing box or hit Enter to confirm the new label.

When hovering over the control item, there are two options you can configure for your control:

  • Delete
  • Specify control behavior by enabling event handlers

Click the trash can icon to delete your control. Click the lightning icon to enable one or more event handlers related to the control. The event handlers are scripts executed whenever the specified event happens. The value of the control is changed by editing, selection is made in a list-like control. When the value of the control is changed, or the focus moves to the control or out from the control, a search must be performed.

The following options are available:

  • OnLeave
  • OnSelect
  • OnSearch
  • OnEnter
  • OnChange

Depending on their type, each control element has a different number of behavior type. The label control does not have an event handler, it can only be deleted.

When the control elements are in place, they are displayed on the scriptable form preview.

After you select a control event, the Form designer automatically switches to Code view, where the selected behavior is included in the code. Alternatively, you have to write the behavior specific script it will use. When the script is complete, click Check to test the script.

If there is any invalid character or piece of code in the window and you click Check, an error message is displayed.

The default script format is the following:


            public Result EvalCode(ICommunicationObject io)
            {
            return Result.Ok;
            }
        

The ICommunicationObject io class provides access to the following members:


        public interfaceICommunicationObject
             {
                  bool HaveToCreateOutputDocument { get; set; }
                  ITypedLogger Logger { get; set; }
                  List<string> OutputDocuments { get; set; }
                  string ProfileName { get; set; }
                  IPublishing Publishing { get; set; }
                  string RequestText { get; set; }
                  string ResponseText { get; set; }
                  string ErrorText { get; set; }
                  T Get<T>(string name);
                  void Set<T>(string name, T data);
                  ScriptableWorkflowState State { get; set; }
                  Form Form { get; set; }
              }

The members stand for the following:

  • HaveToCreateOutputDocument: Whether the system should generate the final document from the scanned pages. The default value is true. If set to false, then the script developer can access the scanned page images (optionally processed by any document services) and can use them for any purposes (for example to use a third-party OCR or other image processing component).
  • Logger: Creates Verbose, Info, Warning, and Exception level logs about the workflow operation, including the user's profile name.
  • OutputDocuments: If the HaveToCreateOutputDocument flag is set, the list contains the file name(s) of the output document(s).
  • ProfileName: The name of the workflow.
  • Publishing: Information coming from Data Publishing.
  • RequestText: Information coming from the device; not used currently.
  • ResponseText: Information going to the device; can be used instead of ErrorText but in this case the return value of the method should be set to Failed.
  • ErrorText: If there is an error, this test message is displayed on the device; not used currently.
  • Get: Obtains the requested parameters from the defined class objects.
  • Set: Inputs the obtained parameters to the defined class objects.
  • State: The current workflow state.
  • Form: Name of the SDK form object.
  • Request: The request object which contains the information coming from the device.
  • ScannedImages: If the HaveToCreateOutputDocument flag is set, this list will contain the scanned image names.

Initialize Form Script

Under the Initialize Form tab, you can write a script that initializes the Scriptable form. If you are at any other location within the Scriptable Workflows configuration, you can get to this section by clicking the Initialize Form Script workflow item arrow in the workflow item list.

Write a script here if you want to:

  • Fill your form controls with some default values
  • Modify the position of your form controls or change any of their attributes (that determines/influences the control's appearance or behavior)
  • Fill in the list of your list-type controls

If you place a Combo box element into the Form designer along with the following script into the Initialize Form Script tab, 'Cannot communicate with the ShareScan Manager' message occurs.

                FmlElementBase listaelem = new Item();
                listaelem.Id="1"; //it's a must, if ID is empty, exception occurs.
                ComboBox cb = new ComboBox();
                cb=io.Form.GetControl<ComboBox>("dropdownlist_1");
                cb.ItemsDictionary.Add(listaelem);

If the instantiation happens from ListBoxItem() instead of Item(), the script functions properly.

Validate Form Script

Under the Validate Form Data tab, you can write a script that validates the date specified by the user on the Scriptable form. If you are at any other location within the Scriptable Workflows configuration, you can get to this section by clicking the Validate Form Script workflow item arrow in the workflow item list.

Store Result Script

Under the Store Workflow Results tab, you can write a script that stores the final workflow results. If you are at any other location within the Scriptable Workflows configuration, you can get to this section by clicking the Store Result Script workflow item arrow in the workflow item list.