Hi,
I try to create a documentation model using master document containing model document(s).
Everything goes well and works except for the part where I want to SET the name of the RTF Template to use for the master document.
Normally, this should work like this:
[*] Create a package, set stereotype 'master document', name it
[*] as the stereotype has a default TaggedValue of type RTFTemplate, look it up
[*] Set value to name of template (e.g. Master Analysis)
[*] Update package
[/list]
Whatever I tried, setting value, setting notes, setting defaults, ...
I did not succeed putting the right template in, although this is only two clicks in the EA GUI.
So, did I hit a bug in EA scripting?
How should it be done? I prefer to use the EA API.
Extract from the code, developed as a JScript script:
function AddMasterDoc(package, sub, diagram, tree)
{
var thePackage as EA.Package;
thePackage = package;
var subPackageName;
subPackageName = sub + " " + Repository.GetPackageByID(thePackage.ParentID).Name;
subPackage = thePackage.Packages.AddNew(subPackageName, "Package");
subPackage.StereotypeEx = "master document";
subPackage.TreePos = tree;
subPackage.Update();
subPackage.Element.Stereotype = "master document";
subPackage.Update();
var tag as EA.TaggedValue;
subPackage.Element.SynchTaggedValues("Core Extensions", "master document");
tag = subPackage.Element.TaggedValues.GetByName("RTFTemplate");
if (tag == null)
{
tag = subPackage.Element.TaggedValues.AddNew("RTFTemplate", "Master Analysis");
}
else
{
tag.Value = "Master Analysis";
}
// This goes wrong - asked support to help
tag.Notes = "Default: (model document: master template)";
if (!tag.Update())
{
Session.Prompt("Tag Error: " + tag.GetLastError(), promptOK);
}
subPackage.Element.TaggedValues.Refresh();
if (!subPackage.Update())
{
Session.Prompt("MasterDocPackage Error: " + subPackage.GetLastError(), promptOK);
}
return subPackage;
}