Also in this case you can use Set Each Value, it makes the script a bit simpler
Local({dt, newcol},
dt = Current Data Table();
If(!Contains(dt << Get Column Names("String"), "Source"),
newcol = dt << New Column("Source", Character, Nominal, Set Each Value(
dt << get name;
));
);
);
Edit:
A bit cleaned version below, as this doesn't need Local() (I added it for newcol variable to make it easier to remove the formula from created column for the formula version)
If(!Contains(Current Data Table() << Get Column Names("String"), "Source"),
Current Data Table() << New Column("Source", Character, Nominal, Set Each Value(
Current Data Table() << get name;
));
);
-Jarmo