Here is a simple and effective way to rename all fields in the data model, then hide them to front end users using HidePrefix setting.
// Test table 1
Table1:
load * inline [
CompanyID, MarketName
Company1, California
Company2, North Carolina
Company3, Florida
];
// Test Table 2
Table2:
load * inline [
PersonID, PersonName
1, John
2, MadDog
3, Dave
];
// Get list of table names
for t = 0 to NoOfTables()-1
Tables:
load tablename($(t)) as table AutoGenerate(1);
let tablename = peek('table',$(t),'Tables');
// Now get list of each field name within each table
for i = 1 to NoOfFields('$(tablename)')
FieldNames:
mapping load FieldName($(i),'$(tablename)') as OldFieldName,
'Hide.'&FieldName($(i),'$(tablename)') as NewFieldName
AutoGenerate (1);
next i; // next field
next t; // next table
// Rename these field names now
Rename Fields using FieldNames;
// Clean up unwanted table
drop tables Tables;
// Decide whether to hide all fields
let hide = 1;
if $(hide) =1 then
// hide all these fields now
Set HidePrefix = 'Hide';
end if ;