Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save EliJDonahue/9c671d8d5d571f73e99e13c5a78b0ce3 to your computer and use it in GitHub Desktop.

Select an option

Save EliJDonahue/9c671d8d5d571f73e99e13c5a78b0ce3 to your computer and use it in GitHub Desktop.
Sample code for a content generator that displays a tech doc's metadata in an element on the tech doc
//MethodTemplateName=CSharp:Aras.TDF.ContentGenerator(Strict);
// get parent document
string doc_id = executionContext.DocumentId;
Innovator inn = this.Factory.InnovatorInstance;
Item thisDoc = inn.getItemById("tp_Block", doc_id);
if (!thisDoc.isError()) {
// get metadata we want to display from parent document
string num = thisDoc.getProperty("item_number","");
string rev = thisDoc.getProperty("major_rev","") + "." + thisDoc.getProperty("generation","");
DateTime d = DateTime.Parse(thisDoc.getProperty("modified_on",""));
string date = d.ToString("MMMM d, yyyy");
// add a new text element containing each metadata property to the targetElement
// targetElement is the element being created
targetElement.AddChild(this.Factory.NewText("Text", "Document : " + num));
targetElement.AddChild(this.Factory.NewText("Text", "Revision : " + rev));
targetElement.AddChild(this.Factory.NewText("Text", "Date : " + date));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment