Community

How to use Scripts in the DocumentDefinition of the AdministratorStation ? Answered

Hi, I tried adding the following script in my DocumentDefinition in the Administrator Station.

try{

if (Context.Field("ReceiptType").Text==" Diesel "){ 

        Context.Field("Type").Text = " Gas Station ";

    }

}

catch (System.FormatException ex){

     Context.CheckSucceeded = false;

     Context.FocusedField= Context.Field(" ReceiptType ");

     Context.ErrorMessage="Unexpected error while checking value for field " + Context.Field(" ReceiptType ").Name;

     Context.HasRuleError=true;

}

The I for the Script was: If the Engine matches the word Diesel on an Image it writes Gas Station in an empty Type Field.

But it failed regardless if the script is correct, it shows the error:

Type

Script:System.Runtimte.InteropServices.COMExcpetion(0x8004005): No field with name 'ReceiptType'. at ABBYY.FlexiCapture.IRuleContext.Field(String Name) at Main.Execute(IRuleContext Context)

I hope someone can help me solve this since I'm new to scripting in the Administrator Station.

Was this article helpful?

0 out of 0 found this helpful

Comments

2 comments

  • Avatar
    Adrian Enders

    You didn't mention what kind of script this was ... I will assume that it is a rule. Remember that you have to add the field you want to use on the Rule Settings tab in order to use the field. It should also "pop up" when you are typing in the script if you have referenced this correctly.

    If it isn't a rule script, sometimes you have to also reference the section as well as the field name, like this:

    Context.Field("SectionName\\ReceiptType").Text == "Diesel"

    Hop this helps you.

    1
  • Avatar
    Sandra Luehring

    Thank you for your response. I got the script from a solution assistant from Abbyy and he hadn't told me what kind of script it was nor where I should place it. After trial and error I found out that it was a rule script, but I couldn't get it to work. But I found a visual basic .Net script online which worked. It doesn't create a new field but overwrites the existing one.

    dim strStation as string = Context.Field("ReceiptType").Text   if(strStation = "DIESEL" or strStation = "Diesel" or strStation = "diesel") then
        Context.Text = "Gas Station"
    end if
    0

Please sign in to leave a comment.