How to modify table content and add table rows from the script rule?



How to modify table content and add table rows from the script rule?



  1. In order to modify a table cell content, please create a script rule on the section (top) level:
  2. You would only need your table column to be specified in the rule settings (column alias is  AlternativesCustomerName):
  3. Here is the rule text:
    Context.Field("AlternativesCustomerName").Items[0].Text = "test";
  4. In order to add a table row, please use the event triggered After document rules are checked. Adding a new row is not available from the field rule script:
  5. Here is the script text:
    // if no rows, then add one

    if (Document.Field("Commercial Invoice\\Alternatives").Items.Count < 1) {

        Document.Field("Commercial Invoice\\Alternatives").Items.AddNew(0);


Note: you may use any text field with a “flag” content instead of checking Document.Field("Commercial Invoice\\Alternatives").Items.Count < 1.

Please be careful to avoid endless cycle, because this event is triggered again and again: if it adds new rows to the table => table is changes => rules are checked again => “After document rules are checked” is triggered.

Have more questions? Submit a request


1 comment

  • Avatar


    using Document.Field gives me the error "The name Document does not exist in the current Context". How can I resolve this. How do I pass the IDocument Argument ?


Please sign in to leave a comment.