> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring a document processing with verification scenario

> Configure an M-Files workflow and FlexiCapture project for processing with verification, creating a Web Verification Station URL stored in document properties.

## 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"](/flexi-capture/connectors/configuring-a-workflow-in-m-fi) section and then:

1. In the M-Files Admin application navigate to **Connections to M-Files Server** → **Local Computer** → **Document 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
```

<Warning>
  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.
</Warning>

<Note>
  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.
</Note>

6. Close the Edit VBScript Code window and click **OK** button.
7. 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 Server** → **Local Computer** → **Document Vaults** → **\<Vault\_Name>** and add a new property definition to the document class:

<img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/MF-3.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=c3e025ea50a094770e0db7ac059de3e3" alt="" width="629" height="496" data-path="images/flexi-capture/connectors/MF-3.png" />

8. 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.

<Note>
  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:
</Note>

<img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/MF-6.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=3a9905f394286354decf15ae6bff7917" alt="" width="807" height="344" data-path="images/flexi-capture/connectors/MF-6.png" />

9. Create a new state and give it a name (e.g. "Waiting for verification") by repeating steps 1 through 3.
10. 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:

<img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/MF-4.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=48531657a11d416b1a533c1a26503881" alt="" width="771" height="600" data-path="images/flexi-capture/connectors/MF-4.png" />

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.

11. 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:

<img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/MF-5.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=1715c1c85213b64cb3e5fa3d041049ac" alt="" width="853" height="613" data-path="images/flexi-capture/connectors/MF-5.png" />

This state indicates that the document is ready for approval.

Below we provide a sample workflow for processing of documents in FC with verification:

<img src="https://mintcdn.com/abbyy/KEmWsO92hkr7eybZ/images/flexi-capture/connectors/MF-2.png?fit=max&auto=format&n=KEmWsO92hkr7eybZ&q=85&s=1ad0222d360829343c0410ba8a3a920d" alt="" width="590" height="436" data-path="images/flexi-capture/connectors/MF-2.png" />

## Configuring your ABBYY FlexiCapture project

<Warning>
  For the correct operation of the verification scenario, the workflow requires some additional configuration in FC.
</Warning>

1. To configure the workflow in FC, click **Project → Project properties**, select **Schema: Advanced** on the **Workflow** tab, and 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");
```

7. Click **OK**.

<Warning>
  You must also [configure an export profile](/flexi-capture/connectors/m-files/mf-export-config) in the FlexiCapture project that will send processing results back to M-Files.
</Warning>
