How to reference the ItemType in the current tab in a Dialog box?

オフライン

I'm working on a client side method to clone an ItemType using a dialog box. My approach is to make a form with a check box to choose to copy properties and another check box to copy values from a relationship tab, and a button for "Done" and "Cancel." Then opening that form inside a dialog box that's opened from a menu button. My problem is referencing the ItemType in the current tab from the dialog box.

I tried adding the item as an argument to the dialog using the 'item' tag, but using document.thisItem returns 'undefined' for me. 

  • I figured this out five minutes after posting it. For me, the context item reference was parent.newItem. So the basic method I made is as follows. It will clone an ItemType in a new tab with the current ItemType's chosen properties when you close the dialog box. 

    var inn = new Innovator();
    var newItem = inn.newItem("ItemTypeName","add");

    var fetchForm = top.aras.getItemByName("Form", "CloneFormName");
    var currItem = parent.thisItem;

    // set arguments being passed to dialog
    var params = {
    title: 'Clone Form',
    formId: fetchForm.getAttribute("id"), // put your form's id here
    aras: top.aras,
    isEditMode: true,
    dialogWidth: 400, // set width int
    dialogHeight: 300, // set height int
    content: 'ShowFormAsADialog.html',
    item: currItem
    };

    var callback = function() {
    //Perform logic using dialog result here
    newItem.getItemByIndex(0).setProperty("config_id", params.item.getProperty("config_id"));
    newItem.getItemByIndex(0).setProperty("created_by_id", params.item.getProperty("created_by_id"));
    newItem.getItemByIndex(0).setProperty("created_on", params.item.getProperty("created_on"));
    newItem.getItemByIndex(0).setProperty("id", params.item.getProperty("id"));
    newItem.getItemByIndex(0).setProperty("permission_id", params.item.getProperty("permission_id"));

    return top.aras.uiShowItemEx(newItem.node, "tab view", false, false); // in new tab
    };

    // open the dialog
    var topWnd = top.aras.getMostTopWindowWithAras();
    var wnd = topWnd ? topWnd : window;
    wnd.ArasModules.MaximazableDialog.show("iframe", params).promise.then(callback);