Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
8 years ago

Open created related item form

Hello, I would like that after a specific user action on an item's form (select a certain value in a DDL or click on a button), the form to create a related item opens just as if the user used the 'new relationship' button with 'created related' selected. Is there a function in JavaScript that could do that? Especially i would like to be able to open the form to create a related item of a related item of the item (knowing the related item id) Second question is it possible to change the pre selected value Created related / pick related in the DDL or remove the 'No related' option ? Thank you. Léo

2 Replies

  • Hi Leo, I have written the sample below using the Part Document relationship to show how you can add a new relationship and then open the form of the new related item.
    var relshipID = aras.getRelationshipTypeId("Part Document");
    var srcItem = aras.getItemById("Part", "579766B0E0914B399016CBFE2BDF531E");
    // Create the new related item
    var relatedItem = aras.newItem("Document");
    // Create the relationship
    var temp = aras.newRelationship(relshipID, srcItem, false, this, relatedItem, "Document");
    // Show the new related item
    aras.uiShowItemEx(relatedItem, 'tab view', false, false);
    Please note that this sample is intentionally simplified and does not do things like:
    • Ensure the parent item is locked
    • Synchronize the data between the related item's form and the row in the parent item's relationship grid
    To answer your second question, you can remove the "No related" option by checking the "Requires Related" flag on the RelationshipType in question. Beyond that, I do not believe that it is possible to change the which option is available by default. If the "Pick Related" option is enabled, it will always be displayed first. Chris __________________________________ Christopher Gillis Aras Labs Software Engineer
  • As always thanks for the quick response Chris ! Works perfectly fine and thanks for the infos ! Have a nice day ! :) Léo