Created
June 15, 2017 17:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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