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 - JS functions to open dialog for creating/deleting items and relationships

Jeroen Bosch - Monday, June 8, 2015 9:03 AM:

Hi all,

I am aware of the JS function "top.ui.ShowItem(itemTypeName, itemID, viewMode)" which open an item based on its type and Id in a new window.

But I didn't find an equivalent JS function to 1) create an item 2) delete an item 3) pick a related item 4) remove an existing relationship.

Did I miss something?

Jeroen



JensRollenmueller - Friday, July 31, 2015 4:16 AM:

Jerone,

all this JS.Methods are available on the item itself:

e.g.:

//=======================

var myItem = inn.newItem("Part","get");

myItem.setProperty("item_number","0815");

myItem = myItem.apply();

myItem.apply("delete"); // delete a item or a relationship

// =======================

// add a Item

var myItem = inn.newItem("Part","add");

myItem.setProperty("item_number","0815");

myItem = myItem.apply();

// =======================

// add a relationship

var myItem = inn.newItem("Part BOM","add");

myItem.setProperty("source_id","id of parent");

myItem.setProperty("related_id","id of child");

myItem = myItem.apply();

// =======================

// delete a relationship

var myItem = inn.newItem("Part BOM","delete");

myItem.setProperty("source_id","id of parent");

myItem.setProperty("related_id","id of child");

myItem = myItem.apply();

// =======================

These are only examples - I did not check if the code works.