This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Creating BOM with multiple parts

John Example - Tuesday, October 6, 2015 11:04 AM:

Hi everyone,

I need to add multiple parts to BOM structure. Instead of this my method adds only the first Item from each table to a parentItem.

I have the following code:

 

parentItem = CreateNewItem(ref inn, "Part", parentItemNumber.ToString(), parentItemName);

parentItem.apply();

for (int j= 0; j < rowsCount; j++)

{

string firstrowvalue = dataSet.Tables[i].Rows[j][0].ToString();

string secondrowvalue = dataSet.Tables[i].Rows[j][1].ToString();

string thirdrowvalue = dataSet.Tables[i].Rows[j][2].ToString();

 

Item bomItem = inn.newItem("Part BOM","add");

bomItem.setProperty("quantity", secondrowvalue);

 

Item relatedItem = inn.newItem("Part","add");

relatedItem = CreateNewItem(ref inn, "Part", firstrowvalue, thirdrowvalue);

 

parentItem.setAction("edit");

 

bomItem.setRelatedItem(relatedItem);

parentItem.addRelationship(bomItem);

Item resultItem = parentItem.apply();

}

 

I double checked variable rowsCount and it's OK. Any suggestions where I could mess up?

Thank you in advance.