Innovator inn = this.getInnovator();
// ************* Testing - Use ID "1099103A004C431AB08602889B2F3EED" which is an Express ECO
Item ci = inn.newItem("Express ECO","get");
ci.setID("1099103A004C431AB08602889B2F3EED");
// ********************* End Testing
Item affectedItems = inn.newItem("Express ECO Affected Item","get");
ci.addRelationship(affectedItems);
ci = ci.apply();
if (ci.isError())
{
return inn.newError("Error retrieving Express ECO item. Contact the PLM system administrator.");
}
// Copy the basic ECO fields from the old ECO to the new one.
string[] ecoFields = new string[] {"_non_recurring_cost","_recurring_cost","_recurring_cost_direction","_release_for_purpose_intent","change_reason",
"classification","description","owned_by_id","team_id","title"};
Item eco = inn.newItem("Express ECO","add");
for ( int i = 0; i < ecoFields.Length; i++)
{
eco.setProperty(ecoFields[i],ci.getProperty(ecoFields[i],""));
}
Item afi = ci.getItemsByXPath("//Item[@type='Affected Item']");
// Create a new Affected item for each affected item in the old ECO
// Use the "final" Revision number as the input into the new ECO
for ( int j = 0; j < afi.getItemCount(); j++)
{
Item itm = afi.getItemByIndex(j);
Item newAi = inn.newItem("Affected Item","add");
Item newAiRel = inn.newItem("Express ECO Affected Item","add");
newAi.setProperty("affected_id",itm.getProperty("new_item_id"));
newAi.setProperty("affected_type",itm.getProperty("affected_type"));
newAi.setProperty("affected_rev",itm.getProperty("new_item_rev"));
newAiRel.setRelatedItem(newAi);
eco.addRelationship(newAiRel);
}
Item result = eco.apply();
if ( result.isError() )
{
return inn.newError("Error creating ECO based on this one. XML for new ECO: " + eco.node.OuterXml );
}
return this;
Any suggestions what I might be missing to have this create a valid Express ECO?
Thanks,
Brian.