Sparx Systems Forum

Discussion => Automation Interface, Add-Ins and Tools => Topic started by: naxx on August 26, 2016, 11:34:11 pm

Title: Element - set GUID method
Post by: naxx on August 26, 2016, 11:34:11 pm

How I can set my own GUID to element? Is it possible?

Title: Re: Element - set GUID method
Post by: Geert Bellekens on August 26, 2016, 11:52:23 pm
No (unless you go through the backdoor and issue an SQL update statement).
Why would you want that?

Title: Re: Element - set GUID method
Post by: naxx on August 27, 2016, 12:00:55 am
Thanks. I want set GUID to element, because I have XML file with GUIDs (that was parsed and imported to EA) and I want same elementīs GUID.
Title: Re: Element - set GUID method
Post by: Benny on December 12, 2017, 06:05:46 am

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()

      // 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);
SQL = "UPDATE `t_object`"+
"SET     `ea_guid`='{"+reqGUID+"}'"+
"WHERE `Object_ID`="+requirement.ElementID+";"


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...  :o
So it work fine with the SQL Update :D