Forum Discussion

rif6894's avatar
rif6894
Creator I
6 years ago
Solved

Technical Documentation - created_by_id and affected_part output

I am using the Technical Documentation application to create reports for the Quality Management qs_NCR ItemType. One of the qs_NCR properties is the affected_part which is implemented as an Item ItemType. I have also implemented a foreign property that refers to the  affected_part's name.

The method I am using to get the NCR information is:

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

TableDocumentElement tableElement1 = (TableDocumentElement) this.Factory.NewTable("Table", 1, 4);

tableElement1.GetCell(0,0).AddChild(this.Factory.NewText("Title", "Part Name:"));
tableElement1.GetCell(0,1).AddChild(this.Factory.NewText("Text", targetItem.GetItemProperty("_affectedpartnumber", " ")));

tableElement1.GetCell(0,2).AddChild(this.Factory.NewText("Title", "Initiator:"));
tableElement1.GetCell(0,3).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("created_by_id", " ")));


targetItem.AddChild(tableElement1);

}

The output is the created_by_id id, not the user's name.

What is the most efficient way of outputting the user's name?

  • rif6894's avatar
    rif6894
    6 years ago

    AJ

    Thanks for your response. Based on your feedback I have implemented:

    Innovator inn = this.Factory.InnovatorInstance;
    Item item = inn.newItem("User", "get");
    item.setID(targetItem.GetItemProperty("created_by_id", " "));
    Item results = item.apply();
    tableElement1.GetCell(0,4).AddChild(this.Factory.NewText("Title", results.getProperty("keyed_name")));

2 Replies

  • asebastian's avatar
    asebastian
    Community Manager

    Hi Rif,

    The "keyed_name" of the user itemType is Firstname/Lastname. I'd recommend doing a query using the id you can get from targetItem.GetItemProperty("created_by_id", " ") and getting the keyed name of the returned user item. 

    AJ

    • rif6894's avatar
      rif6894
      Creator I

      AJ

      Thanks for your response. Based on your feedback I have implemented:

      Innovator inn = this.Factory.InnovatorInstance;
      Item item = inn.newItem("User", "get");
      item.setID(targetItem.GetItemProperty("created_by_id", " "));
      Item results = item.apply();
      tableElement1.GetCell(0,4).AddChild(this.Factory.NewText("Title", results.getProperty("keyed_name")));