コミュニティ

Database lookup - stop if not found

 

Hi,

 

I’ve been working with Kofax KC/KTM for the last 7+ years, so please bear over with me if asking questions that seems newbie :-)

 

 

During the years, we have sold many Invoice-projects where the invoice number is validated.

 

Is it possible to make a database check that works in “reverse way”, because it should stop only if the invoice number has already been registered?

 

If the invoice number is not found in the database everything is fine.

Thanks in advance.

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

3件のコメント

  • Avatar
    Permanently deleted user

    Hello,

    Could you please describe your purpose and scenario in more details? If you want to check the recognized value from image you may create the database check rule.

    0
  • Avatar
    Claus Nielsen

    Hi again,

    When processing invoices from a vendor they might send the same invoice both on e-mail and physical paper. For example the e-mail could arrives today and the paper in 2 days.

    I know in the standard invoice projekt there is no validation, but I was wondering if it's possible to make the following validation:

    The invoice number (invoice from the e-mail) should be validated agains the ERP system (using the vendor number as a parameter). If NO result is found (meaning the invoice has not been registered before), it should just continiue.

    2 days later the same invoice arrives on paper and someone scans it.

    Now the invoice has allready been registered in the ERP system and FC should stop with an error telling that the invoice number has allready been registered and the user should the delete in invoice.

    0
  • Avatar
    Permanently deleted user

    Hi Diskboy,   Please see rule script I am using below and let me know if you have any questions.   This uses Invoice Number, SupplierNumber(Vendor Number),and Invoice amount to check for duplicates in a table. If a duplicate is found it then updates called duplicatefound with "duplicate". If a no duplicate is found it updates the fields with "No Duplicate" You can then make set the allowed values to "No Duplicate" for the duplicate found field so that it will stop at verification if it is any other value.   You first need to create an ODBC environment variable to use in the connection string.      

    using System;

    using System.Data;

    using System.Data.SqlClient;

    using System.Collections.Generic;

     

    string invNumber = Context.Field("InvoiceNumber").Text;

    string invTotal = Context.Field("Total").Text;

    decimal intTotal = 0;

    string invSupplier = Context.Field("SupplierNumber").Text;

     bool isNumeric = decimal.TryParse(invTotal, out intTotal);

    int invCount = 0;

     string dbConn = FCTools.ScriptContext.Project.EnvironmentVariables.Get("DBVariable).Replace("Provider=SQLOLEDB.1;","").Replace(";Provider=SQLOLEDB.1;","");

    if(invNumber != "" && invTotal != "" && invSupplier != "" && isNumeric == true)

    {

        try

        {

            using (SqlConnection oSqlConnection = new SqlConnection(dbConn))

            {

                oSqlConnection.Open();

                string strSql = "SELECT COUNT(INVOICE_NUM) AS InvCount FROM hsi.v_MTS_Oracle3MonthInvoice WHERE INVOICE_NUM = @InvNum AND VENDOR_ID = @SupNum  AND INVOICE_AMOUNT = @InvTotal group by invoice_num, VENDOR_ID, INVOICE_AMOUNT";

                using (SqlCommand oSqlCommand = new SqlCommand(strSql, oSqlConnection))

                {

                    oSqlCommand.Parameters.AddWithValue("@InvNum", invNumber);

                    oSqlCommand.Parameters.AddWithValue("@InvTotal", invTotal);

                    oSqlCommand.Parameters.AddWithValue("@SupNum", invSupplier);

                    int count = Convert.ToInt32(oSqlCommand.ExecuteScalar());

                    if (count > 0) //Part Found

                    {

                        Context.Field("DuplicateFound").Text = "Duplicate";

                        return;

                    }

                    else

                    {

                        Context.Field("DuplicateFound").Text = "No Duplicate";

                    }

                }

                oSqlConnection.Close();

            }

        }

        catch (System.Exception oException)

        {

            FCTools.ShowMessage(oException.ToString());

        }

    }

    1

サインインしてコメントを残してください。