In my recent upgrade project that I took over in the middle of the upgrade process I had to use a small trick to fix many table and field mappings errors in the Data upgrade checklist
static void addFields(Args _args)
{
TreeNode treeNode;
AOTTableFieldList fieldList;
#AOT
ReleaseUpdateBulkCopyField fields;
ReleaseUpdateBulkCopyTable tables;
DEL_SqlDictionary del_sql;
SqlDictionary sql;
str newTableName;
str newFieldName;
;
while select RecId from fields
join OldTableName, NewTableName from tables
where fields.Status == ReleaseUpdateBulkCopyFieldStatus::NoMapping
&& fields.OldTableId == tables.oldTableId
join FieldType, StrSize from del_sql
where fields.OldTableId == del_sql.TabId
&& fields.OldFieldSqlName == del_sql.SqlName
{
newFieldName = '';
select fieldsData where fieldsData.RecId == fields.RecId;
if (fieldsData.OldFieldName == 'CREATEDDATE')
newFieldName = 'DEL_CreatedDate';
if (fieldsData.OldFieldName == 'MODIFIEDDATE')
newFieldName = 'DEL_ModifiedDate';
if (newFieldName != '')
{
newTableName = tables.newtablename;
treeNode = TreeNode::findNode(@'\\Data Dictionary\Tables\' + newTableName);
fieldList = treeNode.AOTfindChild('fields');
fieldList.addDate(newFieldName);
SqlDataDictionary::synchronize();
}
}
info('Done');
}
static void addFields(Args _args)
{
TreeNode treeNode;
AOTTableFieldList fieldList;
#AOT
ReleaseUpdateBulkCopyField fields;
ReleaseUpdateBulkCopyTable tables;
DEL_SqlDictionary del_sql;
SqlDictionary sql;
str newTableName;
str newFieldName;
;
while select RecId from fields
join OldTableName, NewTableName from tables
where fields.Status == ReleaseUpdateBulkCopyFieldStatus::NoMapping
&& fields.OldTableId == tables.oldTableId
join FieldType, StrSize from del_sql
where fields.OldTableId == del_sql.TabId
&& fields.OldFieldSqlName == del_sql.SqlName
{
newFieldName = '';
select fieldsData where fieldsData.RecId == fields.RecId;
if (fieldsData.OldFieldName == 'CREATEDDATE')
newFieldName = 'DEL_CreatedDate';
if (fieldsData.OldFieldName == 'MODIFIEDDATE')
newFieldName = 'DEL_ModifiedDate';
if (newFieldName != '')
{
newTableName = tables.newtablename;
treeNode = TreeNode::findNode(@'\\Data Dictionary\Tables\' + newTableName);
fieldList = treeNode.AOTfindChild('fields');
fieldList.addDate(newFieldName);
SqlDataDictionary::synchronize();
}
}
info('Done');
}
Comments
Post a Comment