31
Automation Interface, Add-Ins and Tools / JavaScript to convert an element to an ArchiMate data object
« Last post by Modesto Vega on February 06, 2026, 10:18:32 pm »Having asked Copilot to write me a JavaScript to convert an class element to an ArchiMate3 data object, Copilot has generated the function below.
It not only did not work. It tried a number of things I was not expecting, specifically:
The only way to get this to work was to use just 1, and comment out 2 and 3. I also don't understand the purpose of 3 & 4.
It has been a long week and I don't think I have the bandwidth to understand this, perhaps somebody can shed some light on why the AI will add 3 & 4. 2 could just be a case of dumb AI.
It not only did not work. It tried a number of things I was not expecting, specifically:
- element.Stereotype = "ArchiMate3::DataObject";
- element.StereotypeEx = "ArchiMate3::DataObject";
- element.MetaType = "ArchiMate3::DataObject";
- Repository.AdviseElementChange(element.ElementID);
The only way to get this to work was to use just 1, and comment out 2 and 3. I also don't understand the purpose of 3 & 4.
It has been a long week and I don't think I have the bandwidth to understand this, perhaps somebody can shed some light on why the AI will add 3 & 4. 2 could just be a case of dumb AI.
Code: [Select]
function convertToArchiMateDataObject(element) {
Session.Output(" 🔄 Converting: " + element.Name);
//
// STEP 1 — Clear stereotypes completely
//
element.Stereotype = "";
element.StereotypeEx = "";
element.Update();
//
// STEP 2 — Apply ArchiMate Data Object stereotype correctly
//
// EA requires this exact format: <MDG>::<Stereotype>
//
element.Stereotype = "ArchiMate3::DataObject";
element.StereotypeEx = "ArchiMate3::DataObject";
//
// STEP 3 — Force MDG meta-type (important!)
//
element.MetaType = "ArchiMate3::DataObject";
//
// STEP 4 — Save and refresh element
//
element.Update();
Repository.AdviseElementChange(element.ElementID);
Session.Output(" ✔ Converted to ArchiMate3::DataObject");
}
Recent Posts