BOM Structure. Add a field

Good morning companions,
I am trying to add a field to the "BOM Structure", impossible, I can't find the key.

In the form "Part MultiLevel BOM Grid" in "HTML Code" there is the function:

function getItemTree(itemID, queryLevel) {
debugger;
		var treeLoadXml = top.aras.createXMLDocument();
		treeLoadXml.load(xmlFileBase + "query.xml");
		if (treeLoadXml.parseError.errorCode != 0) {
			var loadError = treeLoadXml.parseError;
			top.aras.AlertError("You have error:\n" + loadError.reason);
			return;
		}
		var partBom = treeLoadXml.selectSingleNode("Item/Relationships/Item[@repeatTimes]");
		partBom.setAttribute("repeatTimes", queryLevel);

		var query = innovator.newItem();
		query.loadAML(treeLoadXml.xml);
		query.setID(itemID);
		var results = query.apply();
		if (results.isError()) {
			top.aras.AlertError(results.getErrorString());
			return;
		}
		return results;
	}

Which loads the Query.xml file. In that file is the AML that loads the data:

<Item type="Part" select="name,item_number,locked_by_id,major_rev,state,make_buy" action="GetItemRepeatConfig">
	<Relationships>
     		<Item type="Part BOM" select="related_id,quantity,sort_order,reference_designator" repeatProp="related_id" repeatTimes="0">
			<related_id>
				<Item type="Part"></Item>
			</related_id>
		</Item>
	</Relationships>
</Item>

It seems simple, but no. The function that loads the XML file with the AML code never enters it. I have even deleted the file from the server and it continues to show the same data.

I have managed to add the column to the grid, but I don't know where to add the field from which the value should be taken.

Any ideas?. Keep in mind that I use Version 11.0 SP9 which does not have TGV or anything at all.

This is the code of the method "PE_GetMultilBom":

		Innovator inn = this.getInnovator();
		
		if (!String.Equals(this.getType(), "Part", StringComparison.Ordinal))
		    return inn.newError("Item of type Part required");
		
		string partId = this.getID();
		if (String.IsNullOrEmpty(partId))
		    return inn.newError("Part ID not specified");
		
		DictsForMultiBom dictOfData = new DictsForMultiBom();
		
		GetDataForParsing getDataForParsing = new GetDataForParsing(inn.getUserID(), this);
		getDataForParsing.SetDataToDict(dictOfData);
				
		GetMultiBom ret = new GetMultiBom(CCO);		
		string parsedData4Return = ret.GetCompleteBom(dictOfData);
		
		return inn.newResult(parsedData4Return);
	}
}

class DictsForMultiBom
{
	public Dictionary<string, List<InfoOfItem>> dictAllItems;
	public List<InfoOfItem> zeroLevelItems;
}

class InfoOfItem
{
	public string level;
	public string id;
	public string item_number;
	public string revision;
	public string state;
	public string sort_order;
	public string quantity;
	public string lockedId;
	public string name;
	public string brd;
	
	public string make_buy; //fer
}

class GetDataForParsing
{
	private string thisUserID;
	private Item item;
	
	public GetDataForParsing(string userId, Item part)
	{
		this.thisUserID = userId;
		this.item = part;
	}
	
	public void SetDataToDict(DictsForMultiBom dictOfData)
	{
		Dictionary<string, List<InfoOfItem>> dictItemProp = new Dictionary<string, List<InfoOfItem>>();
		List<InfoOfItem> zeroLevelItems = new List<InfoOfItem>();
		Item itemList = this.GetAllItems();
		
		int itemsCount = itemList.getItemCount();
		if (itemsCount == 0) return;
		
		for (int i = 0; i < itemsCount; i++)
		{
			Item itm =  itemList.getItemByIndex(i);
			InfoOfItem infoOfItem = new InfoOfItem();
			infoOfItem.level = itm.getProperty("level", "");
			infoOfItem.id = itm.getProperty("related_id", "");
			infoOfItem.item_number = itm.getProperty("related_item_number", "");
			infoOfItem.revision = itm.getProperty("related_revision", "");
			infoOfItem.state = itm.getProperty("related_state", "");
			infoOfItem.sort_order = itm.getProperty("sort_order", "");
			
			infoOfItem.make_buy = itm.getProperty("make_buy", ""); // fer
			
			infoOfItem.quantity = itm.getProperty("quantity", "");
			string lockedBY = itm.getProperty("related_locked_by_id", "");
			if (lockedBY != "")
				infoOfItem.lockedId = (lockedBY == this.thisUserID) ? "<img src=\"../images/LockedByMe.svg\" />" : "<img src=\"../images/LockedByMe.svg\" />";
			else
				infoOfItem.lockedId = "<emptytag />";
			infoOfItem.name = itm.getProperty("related_name", "");
			infoOfItem.brd = itm.getProperty("bom_ref_desg", "");
			
			if (infoOfItem.level == "0") zeroLevelItems.Add(infoOfItem);
			
			string source_id = string.Empty;
			source_id = itm.getProperty("source_id", "");
			
			if (source_id == "") continue;
			
			List<InfoOfItem> dataOfItemList;
			
			dictItemProp.TryGetValue(source_id, out dataOfItemList);
			if (dataOfItemList != null)
			{
				dataOfItemList.Add(infoOfItem);
			}
			else
			{
				List<InfoOfItem> datList = new List<InfoOfItem>();
				datList.Add(infoOfItem);
				dictItemProp.Add(source_id, datList);
			}
		}
		
		dictOfData.dictAllItems = dictItemProp;
		dictOfData.zeroLevelItems = zeroLevelItems;
	}
	
	private Item GetAllItems()
	{
		Item callframe = item.newItem("SQL", "SQL PROCESS");
		callframe.setProperty("name", "MultiBom_GetCompleteBom1");
		callframe.setProperty("PROCESS", "CALL");
		callframe.setProperty("ARG1", item.getID());
		
		return callframe.apply();
	}
}

class GetMultiBom
{
	private const String InnovatorCCOUID = "PE_GetRelatedParts_InnovatorCCO";
	
	public GetMultiBom(Aras.Server.Core.CallContext CCO)
	{
		HttpContext.Current.Items[InnovatorCCOUID] = CCO;
	}
	
	private Aras.Server.Core.CallContext GetCCO()
	{
		return (Aras.Server.Core.CallContext)HttpContext.Current.Items[InnovatorCCOUID];
	}
	
	public string GetCompleteBom(DictsForMultiBom dictOfData)
	{
		Dictionary<string, List<InfoOfItem>> dictAllItems = dictOfData.dictAllItems;
		List<InfoOfItem> zeroLevelItems = dictOfData.zeroLevelItems;
		
		StringBuilder itemStylesheet = new StringBuilder();
		this.GetBaseTamplate(itemStylesheet);
		
		if (dictAllItems != null && dictAllItems.Count != 0)
		{
			foreach(InfoOfItem parentItem in zeroLevelItems)
			{
				this.GetParsedData(parentItem, 0, itemStylesheet, dictAllItems);
			}
		}
		itemStylesheet.Append("</table>");
		return itemStylesheet.ToString();
	}
	
	private string Escape(string data)
	{
		return System.Security.SecurityElement.Escape(data);
	}
	
	private void GetParsedData(InfoOfItem iof, int level, StringBuilder itemStylesheet, Dictionary<string, List<InfoOfItem>> dictAllItems)
	{
		List<InfoOfItem> dataOfItemList;
		if (level.ToString() != iof.level) return;
		itemStylesheet.Append("<tr level=\"");
		itemStylesheet.Append(Escape(iof.level));
		itemStylesheet.Append("\" icon0=\"../images/Part.svg\" icon1=\"../images/Part.svg\"><userdata key=\"gridData_rowItemID\" value=\"");
		itemStylesheet.Append(Escape(iof.id));
		itemStylesheet.Append("\" /><td>");
		itemStylesheet.Append(Escape(iof.item_number));
		itemStylesheet.Append("</td><td>");
		itemStylesheet.Append(Escape(iof.revision));
		itemStylesheet.Append("</td><td>");
		itemStylesheet.Append(Escape(iof.state));
		itemStylesheet.Append("</td><td>");
		itemStylesheet.Append(Escape(iof.sort_order));
		itemStylesheet.Append("</td><td>");
		itemStylesheet.Append(Escape(iof.quantity));
		itemStylesheet.Append("</td><td>");
		
		itemStylesheet.Append(Escape(iof.make_buy));  //fer
		itemStylesheet.Append("</td><td>");    //fer
		
		itemStylesheet.Append(iof.lockedId);
		itemStylesheet.Append("</td><td>");
		itemStylesheet.Append(Escape(iof.name));
		itemStylesheet.Append("</td><td>");
		itemStylesheet.Append(Escape(iof.brd));
		itemStylesheet.Append("</td>");
		level++;
		if (dictAllItems.TryGetValue(iof.id, out dataOfItemList))
		{
			foreach (InfoOfItem childBom in dataOfItemList)
				GetParsedData(childBom, level, itemStylesheet, dictAllItems);
		}
		
		itemStylesheet.Append("</tr>");
	}
	
	private void GetBaseTamplate(StringBuilder gridStyle)
	{
		Aras.Server.Core.CallContext CCO = this.GetCCO();
		gridStyle.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
		gridStyle.Append("<table");
		gridStyle.Append(" font=\"Microsoft Sans Serif-8\"");
		gridStyle.Append(" sel_bgColor=\"steelbue\"");
		gridStyle.Append(" sel_TextColor=\"white\"");
		gridStyle.Append(" header_BgColor=\"buttonface\"");
		gridStyle.Append(" expandroot=\"true\"");
		gridStyle.Append(" expandall=\"false\"");
		gridStyle.Append(" treelines=\"1\"");
		gridStyle.Append(" editable=\"false\"");
		gridStyle.Append(" draw_grid=\"true\"");
		gridStyle.Append(" multiselect=\"true\"");
		gridStyle.Append(" column_draggable=\"true\"");
		gridStyle.Append(" enableHtml=\"false\"");
		gridStyle.Append(" enterAsTab=\"false\"");
		gridStyle.Append(" bgInvert=\"true\"");
		gridStyle.Append(" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\"");
		gridStyle.Append(" xmlns:aras=\"http://www.aras.com\"");
		gridStyle.Append(" xmlns:usr=\"urn:the-xml-files:xslt\">");
		gridStyle.Append(" <thead>");                                         
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "item_number").GetAttribute("label") + "</th>");
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "major_rev").GetAttribute("label") + "</th>");
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "state").GetAttribute("label") + "</th>");
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("5E9C5A12CC58413A8670CF4003C57848", "sort_order").GetAttribute("label") + "</th>");
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("5E9C5A12CC58413A8670CF4003C57848", "quantity").GetAttribute("label") + "</th>");
		
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "make_buy").GetAttribute("label") + "</th>");  //fer
		
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("450906E86E304F55A34B3C0D65C097EA", "locked_by_id").GetAttribute("label") + "</th>");
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "name").GetAttribute("label") + "</th>");
		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("5E9C5A12CC58413A8670CF4003C57848", "reference_designator").GetAttribute("label") + "</th>");
		gridStyle.Append(" </thead>");
		gridStyle.Append(" <columns>");
		gridStyle.Append("  <column width=\"220\" edit=\"NOEDIT\"  align=\"l\" order=\"0\" />");
		gridStyle.Append("  <column width=\"40\"  edit=\"NOEDIT\"  align=\"c\" order=\"1\" />");
		gridStyle.Append("  <column width=\"90\"  edit=\"NOEDIT\"  align=\"c\" order=\"2\" />");
		gridStyle.Append("  <column width=\"70\"  edit=\"NOEDIT\"  align=\"c\" order=\"3\" sort=\"numeric\"/>");
		gridStyle.Append("  <column width=\"70\"  edit=\"NOEDIT\"  align=\"c\" order=\"4\" sort=\"numeric\"/>");
		gridStyle.Append("  <column width=\"40\"  edit=\"NOEDIT\"  align=\"c\" order=\"5\" />");
        gridStyle.Append("  <column width=\"40\"  edit=\"NOEDIT\"  align=\"c\" order=\"6\" />");		
		gridStyle.Append("  <column width=\"250\" edit=\"NOEDIT\"  align=\"l\" order=\"7\" />");
		gridStyle.Append("  <column width=\"100\" edit=\"NOEDIT\"  align=\"l\" order=\"8\" />");
		gridStyle.Append(" </columns>");
		gridStyle.Append(" <menu>");
		gridStyle.Append(" 	<emptytag/>");
		gridStyle.Append(" </menu>");
	

Too many thanks!!!!

  • Hi Meupe,

    this question would be easy to answer - if it would not be Innovator 11 :).

    I cannot remember if the BOM structure was database or codetree based. But as far as I remembered I added a "minor_rev" column in the past.

    Can you make a screenshot of the Realtionship View tab? What is used there to render the view? You mentioned the Form "Part MultiLevel BOM Grid". Is this one linked? I expected something in the "Start Page" column.

  • Hello Angela, yes, here are some pics!!:

    Code of this HTML:

    <style type="text/css">
    	@import "../public/styles/controls.css";
    	
    	html, body {
    		overflow: hidden;
    		width: 100%;
    		height: 100%;
    		margin: 0px;
    		padding: 0px;
    	}
    	.sys_f_container, .sys_f_table {
    		width: 100%;
    		height: 100%;
    	}
    </style>
    <script type="text/javascript" src="../javascript/include.aspx?classes=XmlDocument"></script>
    <script type="text/javascript">
    	var grid;
    	var toolbar;
    
    	var innovator = new top.Innovator();
    	var partItemType = top.aras.getItemTypeForClient("Part", "name");
    	var Part_rowIcon = partItemType.getProperty("open_icon");
    	var xmlFileBase = top.aras.getScriptsURL() + "../Solutions/PLM/xml/";
    	var xmlParentBase = top.aras.getScriptsURL() + "../Solutions/PLM/";
    	var currentUserID = top.aras.getCurrentUserID();
    
    	top.aras.registerEventHandler("ItemSave", window, ItemSaveListener);
    
    	window.onresize = fixGridHeight;
    
    	function ItemSaveListener(params) {
    		if (!document.thisItem || document.thisItem.getId() != params.itemID) {
    			return;
    		}
    		initTree();
    	}
    
    	var onload_handler = function () {
    	
    		clientControlsFactory.createControl("Aras.Client.Controls.Public.Toolbar", { id: "bom_toolbar", connectId: "toolbarContainer" }, function (control) {
    				toolbar = control;
    				clientControlsFactory.on(control, {"onClick": onToolbarButtonClick});
    				initToolbar();	
    		});
    			
    		clientControlsFactory.createControl("Aras.Client.Controls.Public.TreeGridContainer",  {connectId: "grid", canEdit_Experimental: function () { return false; }}, function(control) {
    			grid = control;
    			grid.setMultiselect(false);
    			clientControlsFactory.on(grid, {
    				"gridClick": onGridClick,
    				"gridDoubleClick": onGridDoubleClick,
    				"gridMenuInit": onGridMenuInit,
    				"gridMenuClick": onGridMenuClick
    			});
    			initTree();
    			fixGridHeight();
    		});
    	}
    
    
    	function fixGridHeight() {
    		var el = document.getElementById("grid");
    		top.aras.fixLiquidContainerHeight(document, el);
    	}
    
    	window.addEventListener("DOMContentLoaded", onload_handler);
    
    	function initTree() {
    		if (!document.item) //View form in FormTool
    		{
    			return;
    		}
    
    		var resItem = innovator.newItem("Part", "PE_GetMultilBom");
    		resItem.setID(document.item.getAttribute("id"));
    		resItem = resItem.apply();
    		if (resItem.isError()) {
    			top.aras.AlertError(resItem.getErrorString());
    			return;
    		}
    
    		grid.InitXML(resItem.getResult());
    	}
    
    	function getItemTree(itemID, queryLevel) {
    debugger;
    		var treeLoadXml = top.aras.createXMLDocument();
    		treeLoadXml.load(xmlFileBase + "query.xml");
    		if (treeLoadXml.parseError.errorCode != 0) {
    			var loadError = treeLoadXml.parseError;
    			top.aras.AlertError("You have error:\n" + loadError.reason);
    			return;
    		}
    		var partBom = treeLoadXml.selectSingleNode("Item/Relationships/Item[@repeatTimes]");
    		partBom.setAttribute("repeatTimes", queryLevel);
    
    		var query = innovator.newItem();
    		query.loadAML(treeLoadXml.xml);
    		query.setID(itemID);
    		var results = query.apply();
    		if (results.isError()) {
    			top.aras.AlertError(results.getErrorString());
    			return;
    		}
    		return results;
    	}
    
    	// ============================= Toolbar & Menu  Handlers ===============================
    
    	function initToolbar() {
    		document.toolbar = toolbar;
    		toolbar.loadXml(top.aras.getI18NXMLResource("MultiLevelBomToolbar.xml", "../Solutions/PLM/"));
    		toolbar.show();
    	}
    
    	function setControlEnabled(ctrlName, b) {
    		if (!toolbar)
    			return;
    
    		if (b === undefined)
    			b = true;
    		else
    			b = Boolean(b);
    
    		var AT = toolbar.getActiveToolbar();
    		var tbi = AT.getElement(ctrlName);
    		if (tbi)
    			tbi.setEnabled(b);
    	}
    
    	function onToolbarButtonClick(item) {
    		var btnId = item.getId();
    		if ("expandall" == btnId)
    			onExpandAll();
    		else if ("collapseall" == btnId)
    			onCollapseAll();
    		else if ("refresh" == btnId)
    			initTree();
    		else if ("open_row_item" == btnId)
    			onOpenRowItem();
    	}
    
    	function onGridMenuInit(row, col, p) {
    		var mnu = grid.getMenu();
    		mnu.removeAll();
    		mnu.add("open_row_item", "Open Item");
    		mnu.menu.startup();
    	}
    
    	function onGridMenuClick(menuChoice, rowId, col) {
    		if ("open_row_item" == menuChoice)
    			onOpenRowItem(rowId);
    	}
    
    	function onExpandAll() {
    		grid.expandAll(true);
    	}
    
    	function onCollapseAll() {
    		grid.expandAll(false);
    	}
    
    	function onGridDoubleClick(rowId) {
    		onOpenRowItem(rowId);
    	}
    
    	function onGridClick(rowId, column) {
    		setControlEnabled("open", true);
    	}
    
    	function onOpenRowItem(rowId) {
    		if (!rowId)
    			rowId = grid.getSelectedId();
    
    		if (!rowId)
    			return;
    
    		var partId = grid.GetUserData(rowId, "gridData_rowItemID")
    		top.aras.uiShowItem("Part", partId);
    	}
    </script>
    
    <table class="claro" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;" cellspacing="0" cellpadding="0">
    	<tr style="vertical-align: top;">
    		<td id="toolbarContainer">
    		</td>
    	</tr>
    	<tr style="vertical-align: top;">
    		<td id="grid" style="width: 100%; height: 100%;">
    		</td>
    	</tr>
    </table>

    In the line 75 calls to method PE_GetMultilBom.

    Code of PE_GetMultilBom:

    		Innovator inn = this.getInnovator();
    
    //System.Diagnostics.Debugger.Launch(); // fer
    
    		if (!String.Equals(this.getType(), "Part", StringComparison.Ordinal))
    		    return inn.newError("Item of type Part required");
    		
    		string partId = this.getID();
    		if (String.IsNullOrEmpty(partId))
    		    return inn.newError("Part ID not specified");
    		
    		DictsForMultiBom dictOfData = new DictsForMultiBom();
    		
    		GetDataForParsing getDataForParsing = new GetDataForParsing(inn.getUserID(), this);
    		getDataForParsing.SetDataToDict(dictOfData);
    				
    		GetMultiBom ret = new GetMultiBom(CCO);		
    		string parsedData4Return = ret.GetCompleteBom(dictOfData);
    		
    		return inn.newResult(parsedData4Return);
    	}
    }
    
    class DictsForMultiBom
    {
    	public Dictionary<string, List<InfoOfItem>> dictAllItems;
    	public List<InfoOfItem> zeroLevelItems;
    }
    
    class InfoOfItem
    {
    	public string level;
    	public string id;
    	public string item_number;
    	public string revision;
    	public string state;
    	public string sort_order;
    	public string quantity;
    	public string lockedId;
    	public string name;
    	public string brd;
    	
    	public string make_buy; //fer
    }
    
    class GetDataForParsing
    {
    	private string thisUserID;
    	private Item item;
    	
    	public GetDataForParsing(string userId, Item part)
    	{
    		this.thisUserID = userId;
    		this.item = part;
    	}
    	
    	public void SetDataToDict(DictsForMultiBom dictOfData)
    	{
    		Dictionary<string, List<InfoOfItem>> dictItemProp = new Dictionary<string, List<InfoOfItem>>();
    		List<InfoOfItem> zeroLevelItems = new List<InfoOfItem>();
    		Item itemList = this.GetAllItems();
    		
    		int itemsCount = itemList.getItemCount();
    		if (itemsCount == 0) return;
    		
    		for (int i = 0; i < itemsCount; i++)
    		{
    		    
    		    
    		    
    			Item itm =  itemList.getItemByIndex(i);
    			InfoOfItem infoOfItem = new InfoOfItem();
    			infoOfItem.level = itm.getProperty("level", "");
    			infoOfItem.id = itm.getProperty("related_id", "");
    			infoOfItem.item_number = itm.getProperty("related_item_number", "");
    			infoOfItem.revision = itm.getProperty("related_revision", "");
    			infoOfItem.state = itm.getProperty("related_state", "");
    			infoOfItem.sort_order = itm.getProperty("sort_order", "");
    			
    //			infoOfItem.make_buy = itm.getProperty("make_buy", ""); // fer
    			
    			infoOfItem.quantity = itm.getProperty("quantity", "");
    			string lockedBY = itm.getProperty("related_locked_by_id", "");
    			if (lockedBY != "")
    				infoOfItem.lockedId = (lockedBY == this.thisUserID) ? "<img src=\"../images/LockedByMe.svg\" />" : "<img src=\"../images/LockedByMe.svg\" />";
    			else
    				infoOfItem.lockedId = "<emptytag />";
    				
    			infoOfItem.name = itm.getProperty("related_name", "");
    			infoOfItem.brd = itm.getProperty("bom_ref_desg", "");
    			
    //vamos con las pruebas
    //Innovator innovator = this.getInnovator();
    //var this_item = innovator.applyAML("<AML><Item type='Part BOM' action='get'><id>"+infoOfItem.id+"</id></Item></AML>");
    //infoOfItem.make_buy = this_item.getProperty("make_buy");
    
    		
    			if (infoOfItem.level == "0") zeroLevelItems.Add(infoOfItem);
    			
    			string source_id = string.Empty;
    			source_id = itm.getProperty("source_id", "");
    			
    			if (source_id == "") continue;
    			
    			List<InfoOfItem> dataOfItemList;
    			
    			dictItemProp.TryGetValue(source_id, out dataOfItemList);
    			if (dataOfItemList != null)
    			{
    				dataOfItemList.Add(infoOfItem);
    			}
    			else
    			{
    				List<InfoOfItem> datList = new List<InfoOfItem>();
    				datList.Add(infoOfItem);
    				dictItemProp.Add(source_id, datList);
    			}
    		}
    		
    		dictOfData.dictAllItems = dictItemProp;
    		dictOfData.zeroLevelItems = zeroLevelItems;
    	}
    	
    	private Item GetAllItems()
    	{
    		Item callframe = item.newItem("SQL", "SQL PROCESS");
    		callframe.setProperty("name", "MultiBom_GetCompleteBom1");
    		callframe.setProperty("PROCESS", "CALL");
    		callframe.setProperty("ARG1", item.getID());
    		
    		return callframe.apply();
    	}
    }
    
    class GetMultiBom
    {
    	private const String InnovatorCCOUID = "PE_GetRelatedParts_InnovatorCCO";
    	
    	public GetMultiBom(Aras.Server.Core.CallContext CCO)
    	{
    		HttpContext.Current.Items[InnovatorCCOUID] = CCO;
    	}
    	
    	private Aras.Server.Core.CallContext GetCCO()
    	{
    		return (Aras.Server.Core.CallContext)HttpContext.Current.Items[InnovatorCCOUID];
    	}
    	
    	public string GetCompleteBom(DictsForMultiBom dictOfData)
    	{
    		Dictionary<string, List<InfoOfItem>> dictAllItems = dictOfData.dictAllItems;
    		List<InfoOfItem> zeroLevelItems = dictOfData.zeroLevelItems;
    		
    		StringBuilder itemStylesheet = new StringBuilder();
    		this.GetBaseTamplate(itemStylesheet);
    		
    		if (dictAllItems != null && dictAllItems.Count != 0)
    		{
    			foreach(InfoOfItem parentItem in zeroLevelItems)
    			{
    				this.GetParsedData(parentItem, 0, itemStylesheet, dictAllItems);
    			}
    		}
    		itemStylesheet.Append("</table>");
    		return itemStylesheet.ToString();
    	}
    	
    	private string Escape(string data)
    	{
    		return System.Security.SecurityElement.Escape(data);
    	}
    	
    	private void GetParsedData(InfoOfItem iof, int level, StringBuilder itemStylesheet, Dictionary<string, List<InfoOfItem>> dictAllItems)
    	{
    		List<InfoOfItem> dataOfItemList;
    		if (level.ToString() != iof.level) return;
    		itemStylesheet.Append("<tr level=\"");
    		itemStylesheet.Append(Escape(iof.level));
    		itemStylesheet.Append("\" icon0=\"../images/Part.svg\" icon1=\"../images/Part.svg\"><userdata key=\"gridData_rowItemID\" value=\"");
    		itemStylesheet.Append(Escape(iof.id));
    		itemStylesheet.Append("\" /><td>");
    		itemStylesheet.Append(Escape(iof.item_number));
    		itemStylesheet.Append("</td><td>");
    		itemStylesheet.Append(Escape(iof.revision));
    		itemStylesheet.Append("</td><td>");
    		itemStylesheet.Append(Escape(iof.state));
    		itemStylesheet.Append("</td><td>");
    		itemStylesheet.Append(Escape(iof.sort_order));
    		itemStylesheet.Append("</td><td>");
    		itemStylesheet.Append(Escape(iof.quantity));
    		itemStylesheet.Append("</td><td>");
    		
    		itemStylesheet.Append(Escape(iof.make_buy));  //fer
    		itemStylesheet.Append("</td><td>");    //fer
    		
    		itemStylesheet.Append(iof.lockedId);
    		itemStylesheet.Append("</td><td>");
    		itemStylesheet.Append(Escape(iof.name));
    		itemStylesheet.Append("</td><td>");
    		itemStylesheet.Append(Escape(iof.brd));
    		itemStylesheet.Append("</td>");
    		level++;
    		if (dictAllItems.TryGetValue(iof.id, out dataOfItemList))
    		{
    			foreach (InfoOfItem childBom in dataOfItemList)
    				GetParsedData(childBom, level, itemStylesheet, dictAllItems);
    		}
    		
    		itemStylesheet.Append("</tr>");
    	}
    	
    	private void GetBaseTamplate(StringBuilder gridStyle)
    	{
    		Aras.Server.Core.CallContext CCO = this.GetCCO();
    		gridStyle.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    		gridStyle.Append("<table");
    		gridStyle.Append(" font=\"Microsoft Sans Serif-8\"");
    		gridStyle.Append(" sel_bgColor=\"steelbue\"");
    		gridStyle.Append(" sel_TextColor=\"white\"");
    		gridStyle.Append(" header_BgColor=\"buttonface\"");
    		gridStyle.Append(" expandroot=\"true\"");
    		gridStyle.Append(" expandall=\"false\"");
    		gridStyle.Append(" treelines=\"1\"");
    		gridStyle.Append(" editable=\"false\"");
    		gridStyle.Append(" draw_grid=\"true\"");
    		gridStyle.Append(" multiselect=\"true\"");
    		gridStyle.Append(" column_draggable=\"true\"");
    		gridStyle.Append(" enableHtml=\"false\"");
    		gridStyle.Append(" enterAsTab=\"false\"");
    		gridStyle.Append(" bgInvert=\"true\"");
    		gridStyle.Append(" xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\"");
    		gridStyle.Append(" xmlns:aras=\"http://www.aras.com\"");
    		gridStyle.Append(" xmlns:usr=\"urn:the-xml-files:xslt\">");
    		gridStyle.Append(" <thead>");                                         
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "item_number").GetAttribute("label") + "</th>");
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "major_rev").GetAttribute("label") + "</th>");
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "state").GetAttribute("label") + "</th>");
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("5E9C5A12CC58413A8670CF4003C57848", "sort_order").GetAttribute("label") + "</th>");
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("5E9C5A12CC58413A8670CF4003C57848", "quantity").GetAttribute("label") + "</th>");
    		
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "make_buy").GetAttribute("label") + "</th>");  //fer
    		
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("450906E86E304F55A34B3C0D65C097EA", "locked_by_id").GetAttribute("label") + "</th>");
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("4F1AC04A2B484F3ABA4E20DB63808A88", "name").GetAttribute("label") + "</th>");
    		gridStyle.Append("  <th align=\"c\">" + CCO.Cache.GetPropertyFromCache("5E9C5A12CC58413A8670CF4003C57848", "reference_designator").GetAttribute("label") + "</th>");
    		gridStyle.Append(" </thead>");
    		gridStyle.Append(" <columns>");
    		gridStyle.Append("  <column width=\"220\" edit=\"NOEDIT\"  align=\"l\" order=\"0\" />");
    		gridStyle.Append("  <column width=\"40\"  edit=\"NOEDIT\"  align=\"c\" order=\"1\" />");
    		gridStyle.Append("  <column width=\"90\"  edit=\"NOEDIT\"  align=\"c\" order=\"2\" />");
    		gridStyle.Append("  <column width=\"70\"  edit=\"NOEDIT\"  align=\"c\" order=\"3\" sort=\"numeric\"/>");
    		gridStyle.Append("  <column width=\"70\"  edit=\"NOEDIT\"  align=\"c\" order=\"4\" sort=\"numeric\"/>");
    		gridStyle.Append("  <column width=\"40\"  edit=\"NOEDIT\"  align=\"c\" order=\"5\" />");
            gridStyle.Append("  <column width=\"40\"  edit=\"NOEDIT\"  align=\"c\" order=\"6\" />");		
    		gridStyle.Append("  <column width=\"250\" edit=\"NOEDIT\"  align=\"l\" order=\"7\" />");
    		gridStyle.Append("  <column width=\"100\" edit=\"NOEDIT\"  align=\"l\" order=\"8\" />");
    		gridStyle.Append(" </columns>");
    		gridStyle.Append(" <menu>");
    		gridStyle.Append(" 	<emptytag/>");
    		gridStyle.Append(" </menu>");
    	

    i added the field "make_buy", it appears in the grid but without any data.

    In the HTML code of "Part MultiLevel BOM Grid" i see that call a xml file, in the line 89:

    treeLoadXml.load(xmlFileBase + "query.xml");

    Code of query.xml:

    <Item type="Part" select="name, item_number, locked_by_id, major_rev, state, make_buy" action="GetItemRepeatConfig">
    	<Relationships>
         		<Item type="Part BOM" select="related_id, quantity, sort_order, reference_designator" repeatProp="related_id" repeatTimes="0">
    			<related_id>
    				<Item type="Part"></Item>
    			</related_id>
    		</Item>
    	</Relationships>
    </Item>

    I added "make_buy" to the AML code.

    The problem in that never enters to the function that contain it, line 86.

    It never enters that function, so I can't load the data and of course, then I can't take that data.

    You must prepare the data elsewhere.

    Now that I'm thinking about it, I didn't restart the server when I made the changes to the XML file.

    PS: yes, my nightmare is not ARAS INNOVATOR; It's the version of ******* that I'm using, hahaha. I tried to update to version SP10 or SP11, but it gives errors and does not finish updating. We are talking to a company that will budget us for an update. But I don't have much faith.


    Thank you very much.

  • You are one the right track, there is just something missing for the actual data. Have you check the SQL procedure "MultiBom_GetCompleteBom1"? 

  • Ohhh yeah!!!!.

    Thank you very much, it was there. I was blinded by the XML file and I didn't see that call to that SQL procedure.


    Although to be honest I had never seen or messed around with that part of ARAS. We keep learning!!!

    The most curious thing is that the field that I used to test, randomly, was already in the SQL, but it assigned a value to the name of the field.

    Too many thanks!!!!

  • Haha thanks! Sweat smile

    And congrats: You unlocked a new Innovator achievement by discovering the SQL ItemType.

    This one is not documented very well, but is commonly used. 

    You are probably familiar with applySQL. 
    Instead of using applySQL, a more professional variant is to use SQL procedure and functions.