Vladka,
I have a script that I was using with v.2 for renaming relations. Unfortunately I’m a little bit lost in your new object model for v.3. I just need to rename relations and don’t want to spend time to learn v.3 Objects. Could you help me please?
Thanks,
Andrei
// This script renames all relation names and foreing key constraints (replace them by names of parent and child entities)
function main(){
var app = System.GetInterface('Application');
var Model = app.Models.GetObject(0); // first model in Application View
var Log = System.CreateObject('Log');
//Log.Clear();
//Model.ReadOnly = false;
Model.Lock();
for (r=0; r<Model.Relations.Count; r++)
{
Relation = Model.Relations(r);
ParentEntity = Model.GetEntity(Relation.ParentEntityId);
ChildEntity = Model.GetEntity(Relation.ChildEntityId);
// logical names
OldLogicalName = Relation.Name;
ParentName = ParentEntity.Name;
ChildName = ChildEntity.Name;
Relation.Name = ParentName+'_'+ChildName;
// physical names
OldPhysicalName = Relation.FKConstraint;
ParentName = ParentEntity.TableName;
ChildName = ChildEntity.TableName;
Relation.FKConstraint = ParentName+'_'+ChildName;
//Log.Writeln('Relation '+OldLogicalName+' ('+OldPhysicalName+') renamed to '+Relation.Name+' ('+Relation.FKConstraint+')');
Log.Information('Relation '+OldLogicalName+' ('+OldPhysicalName+') renamed to '+Relation.Name+' ('+Relation.FKConstraint+')');
}
//Model.ReadOnly = true;
Model.UnLock();
Alert(‘All relations renamed.’);
}