如何讀取變更流程的受影響物件
poly item就像是一個箱子,可以讓我把蘋果物件或香蕉物件放進去。也就一個容器可以存入不同物件類型(itemtype)的物件。
Affected Item受影響物件中,舊物件欄位、新物件欄位的屬性定義為Change Controlled Item也就屬於poly item。
程式碼如下
Innovator inn = this.getInnovator();
// return inn.newError(this.getID());
Item DCO_Affected_Item = inn.newItem("Express DCO Affected Item", "get");
DCO_Affected_Item.setAttribute("select", "source_id,related_id");
DCO_Affected_Item.setProperty("source_id", this.getID());
DCO_Affected_Item = DCO_Affected_Item.apply();
string res="";
for(int i=0;i<DCO_Affected_Item.getItemCount();i++){
Item temp=DCO_Affected_Item.getItemByIndex(i);
temp=temp.getItemsByXPath("related_id/Item");
if(temp.getProperty("action")=="Add")
{
string new_item_id=temp.getProperty("new_item_id");
Item ChCtrI = inn.newItem("Change Controlled Item","get");
ChCtrI.setAttribute("select","id,classification,itemtype,item_number");
ChCtrI.setProperty("id",new_item_id);
ChCtrI=ChCtrI.apply();
string itm_classfication=ChCtrI.getProperty("classification");
string itm_itemtype=ChCtrI.getPropertyAttribute("id","type");
string itm_item_number=ChCtrI.getProperty("item_number");
}
else if(temp.getProperty("action")=="Change")
{
// string[] action_itm={"new_item_id","affected_id"};
string[] action_itm={"affected_id"};
for(int j=0;j<action_itm.Count();j++){
string new_item_id=temp.getProperty(action_itm[j]);
Item ChCtrI = inn.newItem("Change Controlled Item","get");
ChCtrI.setProperty("id",new_item_id);
ChCtrI=ChCtrI.apply();
string itm_classfication=ChCtrI.getProperty("classification");
string itm_itemtype=ChCtrI.getPropertyAttribute("id","type");
string itm_item_number=ChCtrI.getProperty("item_number");
}
}
else if(temp.getProperty("action")=="Delete")
{
string affected_id=temp.getProperty("affected_id");
Item ChCtrI = inn.newItem("Change Controlled Item","get");
ChCtrI.setProperty("id",affected_id);
ChCtrI=ChCtrI.apply();
string itm_classfication=ChCtrI.getProperty("classification");
string itm_itemtype=ChCtrI.getPropertyAttribute("id","type");
string itm_item_number=ChCtrI.getProperty("item_number");
}
}
return this;