Skip to main content

Configuring an M-Files workflow

To configure the processing of documents in FC with verification, complete steps 1 and 2 described in the “M-Files workflow activity: installation and use” section and then:
  1. In the M-Files Admin application navigate to Connections to M-Files ServerLocal ComputerDocument Vaults<Vault_Name>Workflows and create a workflow by clicking New Workflow… button. Or modify your current workflow.
  2. Select the workflow that you just set up and create a state by clicking New State button.
  3. In the Name field, type a name for the state (e.g. “In Processing by FlexiCapture”).
  4. On the Actions tab of the State Properties window select the Run script option and click Edit Code….
  5. Paste the following script to the Edit VBScript Code window and provide your FlexiCapture connection settings, project name and batch type that you are going to use:
' FlexiCapture connection settings.
szFCServerUrl = "http://FlexiCapture"
'szCompany = "Company" '(Optional) Set tenant name.
szFCUsername = "Username"
szFCPassword = "Password"
szFCProject = "InvoiceDemoProject"
szFCBatchType = "Default"
' M-Files settings.
iVerificationUrlPropDef = 1024 'ID of an M-Files property for verification URL.
' Creates FlexiCapture client. The assembly Abbyy.MFiles.FlexiCapture.Activity.dll must be registered before.
Set oClient = CreateObject("Abbyy.MFiles.FlexiCapture.Activity.FlexiCaptureWebClient")
' Sets the target document context.
oClient.TargetContext.Vault = Vault
oClient.TargetContext.ObjVer = ObjVer
oClient.TargetContext.PropertyValues = PropertyValues
' Sets FlexiCapture connection settings.
oClient.ConnectionSettings.ServerUrl = szFCServerUrl
'oClient.ConnectionSettings.Company = szCompany '(Optional) Tenant name.
oClient.ConnectionSettings.Username = szFCUsername
oClient.ConnectionSettings.Password = szFCPassword
' Sends the target document to FlexiCapture.
iBatchId = oClient.SendTarget(szFCProject, szFCBatchType)
' Try to get verification URL.
szVerificationUrl = oClient.GetVerificationUrl(szFCProject, iBatchId)
' Update verification URL for the target document.
Set oVerificationUrlPropVal = CreateObject("MFilesAPI.PropertyValue")
oVerificationUrlPropVal.PropertyDef = iVerificationUrlPropDef
oVerificationUrlPropVal.Value.Value = szVerificationUrl
Vault.ObjectPropertyOperations.SetProperty ObjVer, oVerificationUrlPropVal
The FC user whose credentials will be specified in the script must have the Scanning operator, Verification Operator and External User roles for the project and batch type specified in the script, or the Administrator role.
The above script, running in “In processing by FlexiCapture” state, sends documents to FC for further processing. The “In processing by FlexiCapture” state will cease, if the document stops at the verification stage in ABBYY FlexiCapture, or if the document skips the verification stage due to its high quality. If the document stops at the verification stage, a URL will be generated linking to the task created for this document on the Web Verification Station. This URL will be written to the document properties in M-Files.
  1. Close the Edit VBScript Code window and click OK button.
  2. To enable the “In processing by FlexiCapture” state to use a script to generate URLs for documents, you need to create a corresponding property. To do this, click Connections to M-Files ServerLocal ComputerDocument Vaults<Vault_Name> and add a new property definition to the document class:
  1. In the Property Definition Properties - New Property Definition dialog box, type a name for the property (e.g. “Verification URL”) in the Name field and specify Data type: Text, Content: Text. In the script code, assign the ID of the property to the iVerificationUrlPropDef variable.
To find out the ID of the newly created property, select the Admin vault in M-Files and expand the Metadata Structure (Flat View) list. Next, select Property Definitions. The list of all property definitions will be displayed in the ID column on the right:
  1. Create a new state and give it a name (e.g. “Waiting for verification”) by repeating steps 1 through 3.
  2. The “Waiting for verification” state indicates that the document will stop at the verification stage in FC. You can set up the document to go into this state if there is a link to the verification stage in the Verification URL field in the document properties:
You can click this URL to verify the document URL. Once the document is verified, it will be sent to the export stage in FC.
  1. Create a new state and give it a name (e.g. “Waiting for approval”) by repeating steps 1 through 3. You can set up the document to go into this state if certain required fields of the document are filled in:
This state indicates that the document is ready for approval. Below we provide a sample workflow for processing of documents in FC with verification:

Configuring your ABBYY FlexiCapture project

For the correct operation of the verification scenario, the workflow requires some additional configuration in FC.
  1. To configure the workflow in FC, click Project → Project properties, select Schema: Advanced on the Workflow tab, then select the Verification and click Edit….
  2. On the General tab, select the Enable web stations option and click OK.
  3. Create a new User type stage after the Verification stage by clicking Stage….
  4. On the General tab, type Mark No Verification in the Name field (be sure not to use any other name for this stage). Clear the linked to previous option.
  5. On the Entry Conditions tab, select the Under these conditions option and add a new rule by clicking Rule….
  6. In the Rule Settings dialog box, select Condition type: Script, open the script editor, select Script Language: C# .Net, and paste the following script code:
Result.CheckSucceeded = (Document.StageInfo.StageName != "Verification Postprocessing" && Document.StageInfo.StageName != "Verification");
  1. Click OK.
You must also configure an export profile in the FlexiCapture project that will send processing results back to M-Files.