How to access the instance of the field inside of the Repeating Group with a Script Rule in ABBYY FlexiCapture 12?
As the field inside the Repeating Group is the collection of the fields, you need to specify its instance in a form of Field("<Field Name>").Items[i] (where i is a number of an instance) to access it.
As an example, the following Script Rule assigns the text of the second instance of the "Designation" field (which is a field inside the Repeating Group) to the "Field" field.
Context.Field("Field").Text = Context.Field("Designation").Items.Text;
what about a nested repeating group? how to access it or get the instance number?
e.g. I want to get Instant 2 , and nested instant 3 in instant 2 --> repeating group [2,3]
I am trying to write a script to loop it but failed.
Depending on what you need, and how your Repeating Groups look like, you could be able to access it the same way as described in an article.
But, it seems to be not possible to access it using the obvious Context.Field("Field").Items[i].Items[j].Text.
If you would like for the Support Team to take a closer look on your question, please submit a request and share your project with us, we will be happy to help.
Thanks, I submitted a request #466232
Yes I tried .Items[i].Items[j] before but no luck.
And items.count will get the number for total item counts, instead of the items count for each individual nested repeating group
Me too, same question have you ever solve it? I found the solution. We should put the script in event handle for nested repeat group
no, still waiting for reply from ABBYY's support.
Could you share us the script?
You should input your script in "after document state changed" Document Definition properties\EventHandlers\After document state changed. Check the option. Then input your script.
You can access each nested repeat group like this
if changedstates.Has(2) =true then
' if Assorment then need to calculate sort ratio
if instr(1,me.Field("KOHL\AssormentOrEach").Text,"Assortment",1)>0 then
' Loop in SizeTable
for H = 0 to me.Field("KOHL\SizeTable").Items.Count-1
sumAssortMent = 0
'Loop in SizeDetails
for I = 0 to me.Field("KOHL\SizeTable").Items(H).Field("SizeDetails").Items.Count-1
sumAssortMent = sumAssortMent + me.Field("KOHL\SizeTable").Items(H).Field("SizeDetails").Items(I).Field("QTY").Text * 1
for I= 0 to me.Field("KOHL\SizeTable").Items(H).Field("SizeDetails").Items.Count-1
QtyRatio = me.Field("KOHL\SizeTable").Items(H).Field("SizeDetails").Items(I).Field("QTY").Text
TotalQty = me.Field("KOHL\SizeTable").Items(H).Field("TotalQty").Text
me.Field("KOHL\SizeTable").Items(H).Field("SizeDetails").Items(I).Field("QTY").Text = FormatNumber(TotalQty * ( QtyRatio / sumAssortMent),0)
You should test the script in working batch or testing batch. Not test the script in document definition.
Thanks for the script, it is working
Dũng Trần Anh
I don't use VB, can you help me convert to C#. Thanks for your help.
Please sign in to leave a comment.