Tech Doc Content automation from CUI Method Call

Hello, 

I've written a CUI method to instantiate a new Tech Doc from within the "Parts" page, and its' fields are set, including which schema to use.

There's a necessity to build out this new corresponding tech doc with a very specific content. I want to insert and start building the Tech Doc programmatically within this method. I've seen this example here:

GitHub - ArasLabs/content-generator-samples: This project contains code snippets to demonstrate how to create and manipulate content in Aras Technical Documents.

//MethodTemplateName=CSharp:Aras.TDF.ContentGenerator(Strict);
ItemDocumentElement targetItem = targetElement as ItemDocumentElement;

if (targetItem != null) {
	targetItem.ClearChilds();

	// if referenced item was set, then
	if (!targetItem.IsEmpty)
	{
		TableDocumentElement tableElement = (TableDocumentElement) this.Factory.NewTable("Table", 3, 5);
		tableElement.GetCell(0, 0).AddChild(this.Factory.NewText("Title", "Item Info Table"));

		for (int i = 0; i < tableElement.CellCount; i++)
		{
			tableElement.MergeCells(0, i, MergeDirection.Right);
		}

		tableElement.GetCell(1, 0).AddChild(this.Factory.NewText("Title", "Id"));
		tableElement.GetCell(1, 1).AddChild(this.Factory.NewText("Title", "Name"));
		tableElement.GetCell(1, 2).AddChild(this.Factory.NewText("Title", "Classification"));
		tableElement.GetCell(1, 3).AddChild(this.Factory.NewText("Title", "Status"));
		tableElement.GetCell(1, 4).AddChild(this.Factory.NewText("Title", "Date of creation"));

		tableElement.GetCell(2, 0).AddChild(this.Factory.NewText("Title", targetItem.ItemId));
		tableElement.GetCell(2, 1).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("name", " ")));
		tableElement.GetCell(2, 2).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("classification", " ")));
		tableElement.GetCell(2, 3).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("state", " ")));
		tableElement.GetCell(2, 4).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("created_on")));

		targetItem.AddChild(tableElement);
	}
}



With aras innovator, inn.newItem("tp_block", "tp_GetDocument");, I am able to reference the document I intend to fetch (considering that it exists at this statement, otherwise I also create it first)

 My main issue to tackle now is how to, with this document variable in cache, create new Item Document Elements, such as a Break, Chapter, Section, etc. Is this possible? Is there a way to get reference to the root Item Document Element?

Thank you

Parents
  • Hi Frank,

    were you able to find a solution already?

    I haven´t fully understand what you want to build, but you should be able to add the custom elements. 

    The root element can be fetched like this:

    string docId = executionContext.DocumentId;
    Innovator inn = this.Factory.InnovatorInstance;
    Item thisDoc = inn.getItemById("tp_Block", docId);

Reply
  • Hi Frank,

    were you able to find a solution already?

    I haven´t fully understand what you want to build, but you should be able to add the custom elements. 

    The root element can be fetched like this:

    string docId = executionContext.DocumentId;
    Innovator inn = this.Factory.InnovatorInstance;
    Item thisDoc = inn.getItemById("tp_Block", docId);

Children
  • Ya I was, although it went much different than expected.

    I am using JavaScript instead of C# for this method.

    I ended up building out the content via an XML document within the cache and then storing that in tp_block's column 'content'. Getting this data to conform to the Technical Documentation renderer was difficult, for example I needed to individually set each XML node's ID for tables & rows, and had to ensure my xml nodes were cleanly appended, in the end mimicing XML which would be created by Aras when using the technical documentation UI.

    Best Regards,

    Frank