Lock Item and all related Items on opening Form

オフライン

What is the code equivalent of clicking the Lock button? I have an ItemType, QN, with a Classification PVN. If a user opens a PVN, I want to run code to make it lock automatically. I've tried top.onLockCommand(), but this only locks the Item itself, not the related Items. I've tried cycling through all the related Items and unlocking them one by one, but this only works if I then click the Refresh button, or close the PVN and re-open it.

Parents
  • As far as I understand your post, you are already able to lock your items. Your main problem is the refresh. Have you tried parent.onRefresh() at the end of your JS codE?

  • 0 オフライン in reply to AngelaIp

    I had, and it hadn't worked, but I was ultimately able to resolve this by setting a timeout on the command, that only allows it to run once the Relationships are fully loaded. Thank you for the assistance.

    setTimeout(refreshForm, 10);

    function refreshForm()
    {
    if (!isTabbarReady()){
    setTimeout(refreshForm, 10);
    return;
    }
    parent.onRefresh();
    }

    {
    var res = Boolean(parent &&
    parent.relationships &&
    parent.relationships.document &&
    parent.relationships.document.readyState == "complete" &&
    parent.relationships.relTabbar &&
    top &&
    top.menuFrame &&
    top.menuFrame.activeToolbar);
    return res;
    }

Reply
  • 0 オフライン in reply to AngelaIp

    I had, and it hadn't worked, but I was ultimately able to resolve this by setting a timeout on the command, that only allows it to run once the Relationships are fully loaded. Thank you for the assistance.

    setTimeout(refreshForm, 10);

    function refreshForm()
    {
    if (!isTabbarReady()){
    setTimeout(refreshForm, 10);
    return;
    }
    parent.onRefresh();
    }

    {
    var res = Boolean(parent &&
    parent.relationships &&
    parent.relationships.document &&
    parent.relationships.document.readyState == "complete" &&
    parent.relationships.relTabbar &&
    top &&
    top.menuFrame &&
    top.menuFrame.activeToolbar);
    return res;
    }

Children
No Data