I want to update "notes" in all workspace with a project name change. There are about 500 plus workspace, in all workspace I have a note with title which has project name and table name.
So..trying to check if there is any shortcut to change the notes with new project name. Please advise. Example: From Project name XYZ to ABC.
Hi Rajesh,
I suppose that "Project Name XYZ" is just plain text in notes. So there is not any centralized place where you can rename it. if you use Stamp object for display Project name and other information, you can rename it in each stamp for all.
In your case it will be solution write simple script to rename. Bellow is fragment of code which should help you
function main(){
var i;
//Go throught all notes in model
for(i=0;i<Model.Notes.Count;i++){
var Note = Model.Notes.GetObject(i);
//Filter out appropriate note
if (Note.Text.search("Project Name XYZ")!=-1)
{
//Here should be placed code for replaced text in Note
Log.Information(Note.Text);
}
}
}
ok... I tried running the script shared by you in TDM scripting window by replacing the notes with new project name. However, getting runtime error message.
First time I am using this scripting window and I'm very sure I'm missing something, could you please email me directly so that I can share the error message ?
Hi Rajesh,
scripting windows is easiest way how to run simple script. So I think it is suitable for this case.
The work with scripting window is easy, maybe you didn't select your model for scripting. Above of script editor is part where are all opened models. In the left part are all available, and you can move to the right part model (or more) which will be accessible in scripting window. BY default is the model accessible via variable "Model", but you can change it by inplace editor (select expression and press F2).
Output are typically to Message explorer, but there are more ways.
Another way to access model form scripting window is global object Application (See class CSApplication in Reference Guide). It has list of all opened models. So code below print names of opened models.
function main(){
var i;
for(i=0;i<Application.Models.Count;i++){
var Mod = Application.Models.GetObject(i);
Log.Information(Mod.Name);
}
}
BTW: You can find property ActiveModel of Application, but when you are in scripting window, there is no active model. This property is possible to use in macros or other, but not in scripting window.
Tried with the script below by selecting the required model, if you look at the script, currently I mentioned only the old name eCash, wondering where I should mention the new name Vergent in the script.
function main(){
var i;
//Go throught all notes in model
for(i=0;i<Model.Notes.Count;i++){
var Note = Model.Notes.GetObject(i);
//Filter out appropriate note
if (Note.Text.search("eCash")!=-1)
{
//Here should be placed code for replaced text in Note
Log.Information(Note.Text);
}
}
}
Successfully script has been executed, but I believe I need to mention the new name somewhere in the script, may be at the end where it says "Here should be placed code for replaced text in Note". Please let me know if I am missing something.
Hi Rajesh,
you are right for your particular case you need code like this
function main(){
var i;
//Go throught all notes in model
for(i=0;i<Model.Notes.Count;i++){
var Note = Model.Notes.GetObject(i);
//Filter out appropriate note
if (Note.Text.search("Display notes:")!=-1)
{
var str = Note.Text;
str = str.replace("Display notes:","Vergent")
//Here should be placed code for replaced text in Note
Note.Text = str;
Log.Information("New: "+Note.Text);
}
}
}
After running the script, when I checked the workspace, it still has the old note. Is there any additional step to apply the changes in all workspace ?
I explored “Script Explorer” by searching with some keyword in help topics.
Looks like I need to save the script in any of the folder in “Script Explorer” and commit the changes. If my understanding is correct, I would like to know how to use "Commit" in the script to apply the changes. I have not used script explorer/scripting window earlier. Please advise.
Follow up clarification - By using the script, I changed the title in "note" few days back for all workspace.
However, I just noticed that if I double click the note, the top portion under "Name" has not changed. Please check the below screen snap, shown in Red.
If I generate an HTML report, for sure it will not show the old name eCash in the workspace. Still trying to check if there is an option or any other script to rename eCash to Vergent in the "Name" section. Please advise.