How do I populate the column of the table with the fixed value?

Question

How to copy a separate field value with the script to populate each table line?

 

Answer

Here is an example of how to copy the Date field value to each table row for the LineDate column of the table:

  1. Open the Document Skill in the editor.
  2. Open the table element > right-click on the table column header to access Column settings:
     


  3.  Click New Rule in the settings, scroll down to Advanced Script Rule, select it, and click Next:

     
  4. Map fields to be used in a rule: date field and the date column of the table, make sure that the date column is also checked to be changed by this rule. Click Next:
     

     
  5. In the script editor insert and save the below code:
//get the extracted date value

var date = Context.GetField("Date").Value;

//get the collection of table dates

var table_dates = Context.GetFields("Table/LineDate");

//iterate through table dates and assign the extracted date value

table_dates.forEach((element) => {
 element.Value = date;
});

 

 As a result, the column is populated with the header field value:
mceclip0.png

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.