function BulkChangeAuthor(){
Session.Output('BulkChangeAuthor Started');
var newAuthor=DLGInputBox('Who is the new papa?', '', '');
updateElementAndChildren(Repository.GetTreeSelectedObject(),newAuthor);
Session.Output('Finished!');
DLGInputBox('Finished!','','OK!');
}
function updateElementAndChildren(theOBJECT,newAuthor)
{
if (theOBJECT.ObjectType == 5 && theOBJECT.Element.Author !=newAuthor){ //if theOBJECT is a package
theOBJECT.Element.Author = newAuthor;
Session.Output('Package Author updated to '+theOBJECT.Element.Author);
theOBJECT.Element.Update();
}
if (theOBJECT.ObjectType == 4 && theOBJECT.Author !=newAuthor){//if theOBJECT is an element
theOBJECT.Author = newAuthor;
Session.Output('Element Author updated to '+theOBJECT.Author);
theOBJECT.Update();
}
if (theOBJECT.ObjectType == 5 && theOBJECT.Packages.Count >0){ //go through all child packages
var packagesEnumerator = new Enumerator(theOBJECT.Packages);
Session.Output('Child Packages found! Processing.');
while (!packagesEnumerator.atEnd()){
Session.Output('Package to process is ' + packagesEnumerator.item().Name);
updateElementAndChildren(packagesEnumerator.item(),newAuthor);
packagesEnumerator.moveNext();
}
}
if (theOBJECT.Elements.Count >0){ //go through all child elements
var elementEnumerator = new Enumerator(theOBJECT.Elements);
Session.Output('Child Elements found! Processing.');
while (!elementEnumerator.atEnd()){
Session.Output('Element to process is ' + elementEnumerator.item().Name);
updateElementAndChildren(elementEnumerator.item(),newAuthor);
elementEnumerator.moveNext();
}
}
}
BulkChangeAuthor();