1
Automation Interface, Add-Ins and Tools / Re: Access content of an Artifact (Internal) with scripts
« on: January 25, 2025, 09:22:08 pm »
I hope I'm not late for the party, but there is a solution using the decodeBase64zippedXML() function of the Geert's framework (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/tree/master). In the example below I'm using another lib for parsing a JSON stored as a content of the artifact element. (For the JSONClass see https://gist.github.com/t3rminus/d278175893dea1ecfed83c29df56a9d8#file-vbsjson-vb).
(I've spent some time trying to find the solution, so I hope this might help someone.)
Code: [Select]
option explicit
!INC Local Scripts.EAConstants-VBScript
!INC Tools.JSONClass
!INC Utils.Include
sub main
' get the content from DB
dim sql
sql = "select BinContent from t_document where DocName = 'data.json'"
dim result
result = Repository.SQLQuery(sql)
dim JSON, configJSON, config
' b64 decode and unzip
configJSON = decodeBase64zippedXML(result, "BinContent")
set JSON = new vbsJSON
' decode JSON
set config = JSON.decode(configJSON)
' use the data
' ...
end sub
main
(I've spent some time trying to find the solution, so I hope this might help someone.)