Forum Discussion

lucas's avatar
lucas
Ideator I
5 years ago
Solved

apply PE_createNewRevision from client method

hello, My initial goal is to have a confirm pop up when using the action to create a new revision.(for parts) I have an action that run a simple client method like this: if(confirm("creation of...
  • Gopikrishnan's avatar
    5 years ago

    Hi Lucas

    Can you update your client side method with below code


    var wnd = aras.getMainWindow();
    var topWnd = aras.getMostTopWindowWithAras(window);
    wnd = wnd === topWnd ? wnd.main : topWnd;
    var selectedId;
    var itemTypeName;
    var innovator = new Innovator();
    if (wnd.parent.main) {
    itemTypeName = wnd.parent.main.work.itemTypeName;
    selectedId = wnd.parent.main.work.grid.getSelectedItemIds();
    } else {
    itemTypeName = wnd.itemTypeName;
    selectedId = [wnd.itemID];
    }
    if (selectedId.length < 1) {
    return;
    }
    var contextItem = innovator.newItem(itemTypeName, "get");
    contextItem.setAttribute("id", selectedId);
    contextItem = contextItem.apply();
    if (!contextItem.isError()) {
    var confirmation;
    confirmation = aras.confirm("creation of new major revision ?");
    if (confirmation !== true) {
    return false;
    } else {
    contextItem.setAction('PE_CreateNewRevision');
    var result = contextItem.apply();
    if (result.isError()) {
    return top.aras.AlertError(result.getErrorString());
    }
    }
    }

    Let me know if it works.

    Thank You

    Gopikrishnan R