1
Automation Interface, Add-Ins and Tools / Re: Element - set GUID method
« on: December 12, 2017, 06:05:46 am »
Hi,
I would also like to set a GUID manually.
When I Import a CSV-File with (valid) GUID inside, the GUIDs where set to the new Elements.
So I consider there musst be a Method to give Input with GUIDs.
I tried to Import it by an script because i like to add a new Connector to existing Elements.
I also tried the "SQL Backdoor" Geert implied, but I got a warning about duplicate Elements.
I also tried the "normal" way to import with the buildin Sparx CSV importer, no Porblems with the GUIDs.
Here is the import function:
May someone got a hint for me
regards Benny
[edit] HAHA never Mind I really got double GUID in the CSV-file (because of a N-N dependency for the System Elements...
So it work fine with the SQL Update
I would also like to set a GUID manually.
When I Import a CSV-File with (valid) GUID inside, the GUIDs where set to the new Elements.
So I consider there musst be a Method to give Input with GUIDs.
I tried to Import it by an script because i like to add a new Connector to existing Elements.
I also tried the "SQL Backdoor" Geert implied, but I got a warning about duplicate Elements.
I also tried the "normal" way to import with the buildin Sparx CSV importer, no Porblems with the GUIDs.
Here is the import function:
Code: [Select]
function OnRowImported()
{
rowCount++;
// get all values for this row
var reqName = CSVIGetColumnValueByName("Name");
var reqType = CSVIGetColumnValueByName("Type");
var reqGUID = CSVIGetColumnValueByName("GUID");
var reqNotes = CSVIGetColumnValueByName("Notes");
var reqAlias = CSVIGetColumnValueByName("Alias");
var reqStereotype = CSVIGetColumnValueByName("Stereotype");
var reqTagValue = CSVIGetColumnValueByName("TagValue");
var systemGUID = CSVIGetColumnValueByName("SystemGUID");
Session.Output(" Importing: " + reqName + "." + reqGUID);
targetPackage = Repository.GetTreeSelectedPackage();
requirement = targetPackage.Elements.AddNew (reqName, reqType);
// requirement.ElementGUID = "{"+reqGUID+"}";
requirement.Notes = reqNotes;
requirement.Stereotype = reqStereotype;
requirement.Alias = reqAlias;
tag = requirement.TaggedValues.AddNew ("Funktional/NichtFunktional",reqTagValue);
tag.Update;
requirement.Update();
SQL = "UPDATE `t_object`"+
"SET `ea_guid`='{"+reqGUID+"}'"+
"WHERE `Object_ID`="+requirement.ElementID+";"
Repository.Execute(SQL);
}
May someone got a hint for me
regards Benny
[edit] HAHA never Mind I really got double GUID in the CSV-file (because of a N-N dependency for the System Elements...

So it work fine with the SQL Update
