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

Question

How do I 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 in the case there is no date for each table row.

1. Open the table element > navigate to the Table LineDate column > right-click on the LineDate table header to access Column settings.
 

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

 
3. 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.
 

 
4. In the opened script body window we insert and save the below code that carries over the extracted date from the additional field to the empty table date cells.

//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 if the corresponding table cell is empty

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

 
Example (the are no dates in the table, but it's carried over from the date field):
 
mceclip0.png

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.