# Configure Data Entry Settings

## Content

Reportsheet supports data entry through the integration with the DataManager. You need to configure the association between specific cells, columns, and tables in the data entry settings of the TemplateSheet.
To configure the data entry settings in the TemplateSheet, follow the below steps:

1. Add Table in DataManager.
2. Configure the remote information for the added table to establish a connection.
3. Design the template sheet according to your requirements, incorporating the necessary cells for data entry.
4. Configure `TemplateCell` information in the `TemplateSheet` class.
    You can also set the `defaultValue` property in `TemplateCell` to generate a default value for newly added records of the report sheet. Note that `defaultValue` is a Formula.
5. Use the `setDataEntrySetting` method of the `TemplateSheet` class to configure the data entry settings.
6. Configure the primary key fields in the write-back rule.

You can use the following code sample to configure the data entry settings and generate a default value for the newly added record.

```javascript
const columns = ['Id', 'Region', 'Salesman', 'Product', 'Sales'];

columns.forEach((columnName, i) => {
     templateSheet.setTemplateCell(3, i, {
            type: "List",
            binding: `Sales[${columnName}]`,
            
            // Generate a random UUID when a new row is inserted for "Id" Column
               defaultValue: i === 0 ? '=SJS.UUID()' : undefined      // Default Value
     })
})

// Configure Data Entry Settings.
const salesRule = {
      name: "test1",           // string
      tableName: "Sales",      // string
      fields: [                // {formula, dbColumnName, isPrimary}
         { formula: 'A4', dbColumnName: 'Id', isPrimary: true },
         { formula: 'B4', dbColumnName: 'Region' },
         { formula: 'C4', dbColumnName: 'Salesman' },
         { formula: 'D4', dbColumnName: 'Product' },
         { formula: 'E4', dbColumnName: 'Sales' }
      ],
      skipRecordWithEmptyValue: true,          
      includeUnmodified: true               
}
// setDataEntrySetting(dataEntrySetting: GC.Spread.Report.DataEntrySetting)
templateSheet.setDataEntrySetting([salesRule]);

reportSheet.refresh();
```