Unable to set Vendor related information

  • 572 Views
  • Last Post 19 February 2019
aroshaj posted this 19 February 2019

Hi Guys, 

I'm experiencing an issue where a vendor lookup is done via a script. I'm getting valid results however when I'm attempting to set a field I'm getting the following error

"Script:System.Runtime.InteropServices.COMException (0x800004005): No field with name VendorId. at ABBYY.FlexiCapture.IRuleContext.Field(String Name) at Main.Execute(IRuleContext Context)"

This is quite strange to me to why this is occurring and any advice would be much appreciated. 

Regards,
AJ

 

Code snippet:

if(!string.IsNullOrEmpty(Context.Field("VATID").Text))

    IDataSet vendorList = Context.DataSet("Vendors");

    IDataSetQuery query = vendorList.CreateQuery();

    query.AddValue("VATID",Context.Field("VATID").Text);

    query.AddValue("CLUB",Context.Field("ClubID").Text);

    IRecordset records = vendorList.GetRecords(query);

    string queryValues = "Query Values: ABN: " +  Context.Field("VATID").Text + " ClubId: " + Context.Field("ClubID").Text; 

    // + " Vendor ID:" + Context.Field("VendorId").Text;

    initial.LogMessage(queryValues + " record Count: " + records.Count.ToString(), "Info"); 

    

    if(records.Count == 1)

    {

        string oneRecord = "One Record Found - " + records.GetRecord(0).GetValue(0).ToString() +" "+ records.GetRecord(0).GetValue(1).ToString() + " " + records.GetRecord(0).GetValue(2).ToString() + " " + records.GetRecord(0).GetValue(3).ToString();

        Context.Field("VendorId").Text = records.GetRecord(0).GetValue(0).ToString();

    }

    else if(records.Count > 1)

    {

        string results = "Multiple Records Found. 0:" + records.GetRecord(0).GetValue(0).ToString() + " 1: " +  records.GetRecord(1).GetValue(0).ToString();

        initial.LogMessage(results, "Info"); 

        if(!Context.Field("VATID").IsVerified)

        {

            Context.CheckSucceeded = false;

            Context.ErrorMessage = "Multiple suppliers with same ABN & Club ID. Please validate.";

            //Context.Field("VATID").NeedVerification = true; 

            //Context.Field("CLUB").NeedVerification = true; 

        }

    }

    else

    {

        Context.CheckSucceeded = false;

        Context.ErrorMessage = "No records were found by combination of ABN & Club ID value.";

    }

}

else

{

        Context.CheckSucceeded = false;

        Context.ErrorMessage = "No records were found.";

}

 

  • Liked by
  • chaseernst
aroshaj posted this 19 February 2019

Hi All, 

Figured it out... It was due to the available fields in the rule being marked as "ReadOnly". 

Hence it caused the above error. Took some time to figure out... But at the end a good result. Hope it may be useful for others as well. 

 

  • Liked by
  • chaseernst
Close