Sparx EA template fragment scripting not outputs any data

524 views Asked by At

Followed this instruction here

Created my own document template fragment wiht custom field inside. Binded custom script to it (code will be below)

Created document template which contain my document template fragment(in template fragment inside custom tag I added custom fields like Author and TimeGen)

Used document generation on it but what I get is an empty document! Why this is happen?

I got Sparx Ea 12 version

Script code (copied from example here)

function MyRtfData(objectID) {
    var i;
    var xmlDOM = new ActiveXObject("Microsoft.XMLDOM");
    xmlDOM.validateOnParse = false;
    xmlDOM.async = false;
    var node = xmlDOM.createProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'");
    xmlDOM.appendChild(node);
    var xmlRoot = xmlDOM.createElement("EADATA");
    xmlDOM.appendChild(xmlRoot);
    var xmlDataSet = xmlDOM.createElement("Dataset_0");
    xmlRoot.appendChild(xmlDataSet);
    var xmlData = xmlDOM.createElement("Data");
    xmlDataSet.appendChild(xmlData);
    var xmlRow = xmlDOM.createElement("Row");
    xmlData.appendChild(xmlRow);
    var xmlName = xmlDOM.createElement("DateGen");
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth() + 1; //January is 0!
    var yyyy = today.getFullYear();
    if (dd < 10) {
        dd = '0' + dd
    }
    if (mm < 10) {
        mm = '0' + mm
    }
    today = mm + '/' + dd + '/' + yyyy;
    xmlName.text = today;
    xmlRow.appendChild(xmlName);
    var xmlName = xmlDOM.createElement("TimeGen");
    var currentTime = new Date()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
    if (minutes < 10) {
        minutes = "0" + minutes
    }
    xmlName.text = hours + ":" + minutes + " ";
    xmlRow.appendChild(xmlName);
    var xmlName = xmlDOM.createElement("Author");
    xmlName.text = Session.UserName;
    xmlRow.appendChild(xmlName);
    var xmlName = xmlDOM.createElement("EA_REPOS");
    xmlName.text = Repository.ConnectionString;
    xmlRow.appendChild(xmlName);
    return xmlDOM.xml;
};

When I running it in debugging mode it seems like okay, it outputs some xml structure, but when I generate document - I got just emtpy sheet

UPD:

Now I get rtf error, and system output just empty

Error looks like that: enter image description here

UPD2:

When I debug it it output valid XML

1

There are 1 answers

0
DanilGholtsman On BEST ANSWER

Problem is solved! By that I mean that I can generate documents with custom fields using template framents + scripts mechanism.

What I've done (long story short - started everything from scratch):

  1. Made new script group
  2. Created there new JScript file (the one above code was contained in Javascript file, maybe it was the reason)
  3. Created new fragment template, made custom Autor field there
  4. Created template, added there my fragment template