Skip to main content

Fundamentals of Relationship Operation with Aras Innovator API

Basic knowledge of operating an item object can refer to "Fundamentals of Item Operation with Aras Innovator API".
This article will introduce operation for relationships with JavaScript.

Assume Part "A0001" need to be created, the code will be:

var inno = aras.IomInnovator;
var itm = inno.newItem('Part', 'add');

itm.setProperty('item_number','A0001');

And the built AML Node seems like below:

<Item isNew="1" isTemp="1" type="Part" action="add" id="052C2E5D160645E9835BAA74AE732265">
    <item_number>A0001</item_number>
</Item>

Create Relationship

Assume Part "A0002" need to be created, and it is the child of "A0001". For another words, "A0002" is Related Item of "Part BOM" Relationship.

Syntax


var relItm = inno.newItem('Part','add');

relItm.setProperty('item_number','A0002');

var rel = inno.newItem('Part BOM','add');

rel.setRelatedItem(relItem);

Built AML Node


<Item isNew="1" isTemp="1" type="Part BOM" action="add" id="91B3A2A9FEEF40259499C7F7D843E5CF">
    <related_id>
        <Item isNew="1" isTemp="1" type="Part" action="add" id="4C37168920194B7FADF4771A969BEF7C">
            <item_number>A0002</item_number>
        </Item>
    </related_id>
</Item>

Add Relationship to Item

Syntax


itm.addRelationship(rel);

Built AML Node


<Item isNew="1" isTemp="1" type="Part" action="add" id="052C2E5D160645E9835BAA74AE732265">
    <item_number>A0001</item_number>
    <Relationships>
        <Item isNew="1" isTemp="1" type="Part BOM" action="add" id="91B3A2A9FEEF40259499C7F7D843E5CF">
            <related_id>
                <Item isNew="1" isTemp="1" type="Part" action="add" id="4C37168920194B7FADF4771A969BEF7C">
                    <item_number>A0002</item_number>
                </Item>
            </related_id>
        </Item>
    </Relationships>
</Item>

Comments