Unlocking an Item with a Method when locked by a User

Hello,

I am attempting to unlock an item when an user has the item locked out for editing and cannot seem to find where to start.

I am doing it on the server side with C#. I have tried Item unlockItem(). Also I have tried AML below.

string my_aml_unlock = "<AML><Item type='smc_TechInquiry' id='" + idNumber + "' action='unlock' /></AML>";
Item result_unlock = inn.applyAML(my_aml_unlock);
if(result_unlock.isError()) {return inn.newError("result_unlock Error: " + result_unlock.getErrorDetail());}

Basically I am trying to re-create what happens when a user is working on an item, then an admin locks their item (takes it away) then once they try to click, save, discard, etc it puts them into a core lock state.

I understand if I get this to work correctly I will be giving the user that had it locked a core lock ever. Any help is appreciated, thank you!

  • Hello,

    Did you try to set the action as 'unlock' like in the example below?

    Item myItem = inn.newItem("MyItemType", "unlock");
    // or
    // myItem.setAction("unlock");
    myItem.setID("myId");
    Item unlockedItem = myItem.apply();
    if (unlockedItem.isError())
    {
        return unlockedItem;
    }

    Additionally, you can try something like this

    // Imagine that you already have the item to unlock, i. e. myLockedItem
    Item unlockedItem = myLockedItem.apply("unlock");
    if (unlockedItem.isError())
    {
        return unlockedItem;
    }

  • I just tried your second technique there with an existing Item and it appears to have the same behavior as my code.

    What is does is after the method is ran the user can update the item and save it. Once they close the item (with it saved and still locked) it will then unlock to the system. 

    Basically I am trying to re-create what happens when a user is working on an item, then an admin locks their item (takes it away) then once they try to click, save, discard, etc it puts them into a core lock state. So after the method is run they could not edit it in anyway.

    Thank you for your help, I did not think of doing it that way.