I don't know why the _order value is NaN.

var prt = typeof(parent.document.item) == "object" ? parent.document : parent.parent;
var tmpThisItem = typeof(parent.document.thisItem) == "object" ? parent.document.thisItem : parent.thisItem;
var NewRels = prt.item.selectNodes("Relationships/Item[@type='" + relationshipTypeName + "' and @isTemp='1']");
if (!NewRels || NewRels.length < 2)
top.aras.getItemRelationshipsEx(prt.item, relationshipTypeName);

var maxVal = 0;
var rels = tmpThisItem.getRelationships(relationshipTypeName);
var count = rels.getItemCount();
for (var i = 0; i < count; i++) {
var rel = rels.getItemByIndex(i);
var _order = parseInt(rel.getProperty("_order"));
if (_order > maxVal) {
maxVal = _order;

var thisRel = tmpThisItem.getItemsByXPath("//Item[@id='" + relationshipID + "']").getItemByIndex(0);
thisRel.setProperty("_order", maxVal + 1);
grid.items_Experimental.set(relationshipID, "value", "_order", maxVal + 1);

  • What datatype do you use for _order? Should be Integer. And don´t forget to define a "Default Value" for your custom order property. Your Method may return NaN when you don´t have any value in the database. A default value prevents this.

    Instead of using a custom property for incrementing the Sequence Number, I would recommend to use add a "sort_order" property the same way as Aras does. This way you can reuse existing Methods and you have some advantage when it comes to Reports or PolyItems were it is important that the table properties are identical.