The following code worked:
!INC Local Scripts.EAConstants-JScript
function main()
{
Session.Output("Got here!");
var reporting as EA.DocumentGenerator;
reporting = Repository.CreateDocumentGenerator();
if(reporting != null)
{
Session.Output("Got here 2!");
if(reporting.NewDocument(""))
{
Session.Output("Got here 3!");
if(!reporting.InsertText("This is some text",""))
{
Session.Output( "Error: " + reporting.GetLastError() );
}
Session.Output("Got here 4!");
var retStr;
retStr = reporting.GetDocumentAsRTF();
Session.Output("Got here 5!");
return retStr;
}
}
}
At least, with your help, I've got the trivial example to work now, which is a major step forward.
Sadly, the code I was intending to use seems to cause EA to crash and shutdown.
Your example code works for me as well, however
ONLY in a case when in template I select custom section -
strange - this is not described in documentation at all!

If custom section is not selected the script is not executed!
Even though this custom section does not refer to output of the script it is included in the final document.
Similarly to you, I also have problems with my intendent script. I got some errors but logs don't say much :-(
Also if I change in my script the
return docGenerator.GetDocumentAsRTF();
into
docGenerator.SaveDocument( OUTPUT_FILE, DOCUMENTATION_TYPE );
EA generates proper document with correct content.
So, my question to you Screwtape is: did you manage to find your way with this new functionality? Maybe you could share what have you learned?
PS. Geert, the Session.Output is visible (when script is actually executed of course)
PS2. I'm using newest version of EA 12.1.1228.
EDIT:Never mind, I managed to fix the problem :-)