Class TableScript
- Namespace
- Dynamicweb.DataIntegration.Integration
- Assembly
- Dynamicweb.DataIntegration.dll
Extensibility point for processing entire source rows during a data integration job. A table script is attached to a table Mapping and its ProcessInputRow(Mapping, Dictionary<string, object>) method is called for every source row before the row is passed on to the destination, allowing the row to be inspected and modified in place. Where ScriptTypeProvider transforms a single column value, a table script sees the whole row and can implement cross-column logic such as calculated values, lookups or validation.
public abstract class TableScript
- Inheritance
-
TableScript
- Inherited Members
Remarks
How to create a custom table script: Subclass this class, implement ScriptingName and
ProcessInputRow(Mapping, Dictionary<string, object>), and deploy the assembly with the solution.
The script is discovered by the add-in system and becomes selectable on table mappings in the data integration
job editor; the selected type name is stored on the mapping and the instance is created through
AddInManager when the job runs, so the class must have a public parameterless constructor.
Things to be careful of:
- ProcessInputRow(Mapping, Dictionary<string, object>) runs once per source row. Keep it fast; do expensive preparation (lookups, caching) in Initialize(Mapping) instead.
- One instance is created per script class per job run and reused for every row — and for every table mapping in the job that references the same script class. Initialize(Mapping) is only called once, with the first mapping that uses the script, so do not assume instance state is per-mapping.
- Modify the row in place using the source column names as keys, and keep the replaced value of the same type as the original value — the row has not yet been through column mapping and type conversion.
- Exceptions thrown from ProcessInputRow(Mapping, Dictionary<string, object>) are caught and logged by the framework; the row still continues to the destination unmodified beyond what the script changed before failing. Throwing does not skip the row or abort the job.
using System;
using System.Collections.Generic;
using System.Linq;
using Dynamicweb.DataIntegration.Integration;
public class FixedPriceTableScript : TableScript
{
public override string ScriptingName => "Fixed product price";
public override void ProcessInputRow(Mapping mapping, Dictionary<string, object> row)
{
var column = mapping.SourceTable?.Columns
.FirstOrDefault(c => c.Name.Equals("ProductPrice", StringComparison.OrdinalIgnoreCase));
if (column is not null && row.ContainsKey(column.Name))
row[column.Name] = 10.5;
}
}
Properties
ScriptingName
Gets the display name shown for the script in the data integration job editor when selecting a table script on a mapping, and used in the log if the script fails.
public abstract string ScriptingName { get; }
Property Value
Methods
Initialize(Mapping)
Called once when the table script instance is created, before the first row is processed. Override to prepare data, build lookup caches or allocate resources used by ProcessInputRow(Mapping, Dictionary<string, object>).
public virtual void Initialize(Mapping mapping)
Parameters
mappingMappingThe table mapping the script was first resolved for. Note that the same instance may subsequently be used for other mappings in the job that reference the same script class.
ProcessInputRow(Mapping, Dictionary<string, object>)
Processes a source row before it is passed on to the destination. Called once per row during job execution; modify the row in place to change the values written to the destination.
public abstract void ProcessInputRow(Mapping mapping, Dictionary<string, object> row)
Parameters
mappingMappingThe table mapping the row belongs to.
rowDictionary<string, object>The source row, keyed by source column name. Replacement values should keep the same type as the original value, as column mapping and type conversion happen after the script runs.