admin 发表于 2018-8-1 13:52:41

【Aras二次开发】通过IOM,AML方式添加对象关系


通过IOM

JavaScript


var innovator = new Innovator();
var partItem = innovator.newItem("Part","add");
partItem.setAttribute("leaveLocked","0");
partItem.setProperty("item_number", "123-456");
partItem.setProperty("description", "Blah blah");

var bomItem = new Item("Part BOM","add");
bomItem.setProperty("quantity", "10");

var relatedItem = new Item("Part","get");
relatedItem.setProperty("item_number", "555-555");

bomItem.setRelatedItem(relatedItem);
partItem.addRelationship(bomItem) ;

var resultItem = partItem.apply();
if (resultItem.isError()) {
top.aras.AlertError(resultItem.getErrorDetail());
return;
}   





AOM方式


JavaScript
var innovator = new Innovator();
var partItem = innovator.newItem();
partItem.loadAML(
"<Item type='Part' action='add' leaveLocked='0'>" +
    "<item_number>123-456</item_number>" +
    "<description>Blah blah</description>" +
    "<Relationships>" +
      "<Item type='Part BOM' action='add'>" +
      "<quantity>10</quantity>" +
      "<related_id>" +
          "<Item type='Part' action='get'>" +
            "<item_number>555-555</item_number>" +
          "</Item>" +
      "</related_id>" +
      "</Item>" +
    "</Relationships>" +
"</Item>"
);

var resultItem = partItem.apply();
if (resultItem.isError()) {
top.aras.AlertError (resultItem.getErrorDetail());
return;
}

页: [1]
查看完整版本: 【Aras二次开发】通过IOM,AML方式添加对象关系