Community

How to add autonumber for lineItems in FC4I?

Hello,
In flexicapture fo invoices i need some script sample to add autonumber for each line item.

Was this article helpful?

0 out of 0 found this helpful

Comments

3 comments

  • Avatar
    Slowdima
    Hi,


    You should create a script rule in any place of your document definition section except for line items repeating group and its children. For example, on section level. Add the child field which instances should be populated by instance numbers into the list of participating fields of the rule and allow modification of this field by the rule. Code of the rule can be something like that ( C# ):






    //===========


    if ( Context.Field("fieldAlias").Items != null ) {


    for ( int i = 0; i < context.field("fieldalias").items.count;="" i++="" )="">


    Context.Field("fieldAlias").Items[ i ].Text = ( i + 1 ).ToString();


    }


    }


    //===========

    0
  • Avatar
    Permanently deleted user
    Thank You Slowdima, the rule works. I tried before the similar code on line items rule
    0
  • Avatar
    Slowdima
    You are welcome Arturasv. I am glad to know that the hint was helpful.

    Regarding to your initial difficulties, if rule is located within repeating document node, then program creates a separate rule instance for each exemplar of the node ( repeating group, table row, section with multiple instances etc. ) So, in this case the rule "sees" only its own exemplar, which does not have Items collection and should be accessed as a usual field. This approach can be used for writing a normalization or validation script, which should work identically for each instance and does not require access to instances collection.
    0

Please sign in to leave a comment.