I'm trying to put an hyperlink in a generated document using a custom script, because the link needs to be fetched by the script.
I'm generating the XML in the custom script like follows:
(...)
var thegeneratedURL = "https://www.google.com"
var thelinktext = "test"
var xmlCommitID = xmlDOM.createElement("CommitID-Hyperlink");
var commitIdLink = xmlDOM.createElement("a");
commitIdLink.setAttribute("href", thegeneratedURL);
var commitIdText = xmlDOM.createTextNode(thelinktext);
commitIdLink.appendChild(commitIdText);
xmlCommitID.appendChild(commitIdLink);
xmlRow.appendChild(xmlCommitID);
return xmlDOM.xml;
Then I'm calling the script in the respective fragment
...and inserting the custom field
However, when I generate the document the link text is fine but the URL is not:
Anybody knows what I'm missing?
Thank you!!
This is the code I use, to link directly to diagram url's on a html export of an EA-Model
function getRTFData(diagram, baseUrl)
dim diagramUrl
diagramUrl = getDiagramLink(diagram, baseUrl)
dim xmlDOM
set xmlDOM = CreateObject( "Microsoft.XMLDOM" )
'set xmlDOM = CreateObject( "MSXML2.DOMDocument.4.0" )
xmlDOM.validateOnParse = false
xmlDOM.async = false
dim node
set node = xmlDOM.createProcessingInstruction( "xml", "version='1.0'")
xmlDOM.appendChild node
'
dim xmlRoot
set xmlRoot = xmlDOM.createElement( "EADATA" )
xmlDOM.appendChild xmlRoot
dim xmlDataSet
set xmlDataSet = xmlDOM.createElement( "Dataset_0" )
xmlRoot.appendChild xmlDataSet
dim xmlData
set xmlData = xmlDOM.createElement( "Data" )
xmlDataSet.appendChild xmlData
dim xmlRow
set xmlRow = xmlDOM.createElement( "Row" )
xmlData.appendChild xmlRow
dim formattedAttr
set formattedAttr = xmlDOM.createAttribute("formatted")
formattedAttr.nodeValue="1"
dim xmldiagramLink
set xmldiagramLink = xmlDOM.createElement( "DiagramLink" )
xmldiagramLink.text = "<a href=""$inet://" & diagramUrl &"""><font color=""#0000ff""><u>" & diagram.Name & "</u></font></a>"
xmldiagramLink.setAttributeNode(formattedAttr)
xmlRow.appendChild xmldiagramLink
getRTFData = xmlDOM.xml
end function
function getDiagramLink(diagram, baseUrl)
dim link
link = baseUrl & "/?guid="
'get diagram GUID
link = link & diagram.DiagramGUID
'remove braces
link = replace(link, "{","")
link = replace(link, "}","")
'return
getDiagramLink = link
end function
function getObjectDiagramLink(objectID, baseUrl)
dim element
set element = Repository.GetElementByID(objectID)
'get diagram
dim diagram
set diagram = getFirstDiagram(element)
'get the xml data
getObjectDiagramLink = getRTFData(diagram, baseUrl)
end function
function getFirstDiagram(diagramOwner)
set getFirstDiagram = nothing 'initialize
'get first diagram
dim diagram as EA.Diagram
for each diagram in diagramOwner.Diagrams
set getFirstDiagram = diagram
exit function
next
end function
This code is used in a script fragment like this:
getObjectDiagramLink(#OBJECTID#, "https://urlToHTMLExport.com")
It generates a link like the following:
https://urlToHTMLExport.com/?guid=B79FA03B-33F3-46b7-8F97-3DDE8E653753
with the name of the diagram being displayed.