BPM, Workflow, and Case

 View Only
  • 1.  Unlock Work item in BAW Case Client

    Posted Thu May 16, 2019 08:38 AM
    Hi Team,
    Can someone please provide code snippet to unlock a work item in BAW Case Client?

    Regards,
    Faisal Meraj

    ------------------------------
    Faisal Meraj
    ------------------------------


  • 2.  RE: Unlock Work item in BAW Case Client

    Posted Fri May 17, 2019 12:52 PM
    Script Action menu on In-basket to unlock any users work item

    Enter this in the Execute Script section

    var self = this;
    var selectedWorkItems = this.getActionContext("WorkItemReference");
    var selectedWorkItemCount = selectedWorkItems.length;
    var doRefresh = false;
    if (confirm('Are you sure you want to unlock this item?')) {
    for (var i=0; i<selectedWorkItemCount; i++) {
    var workItem = selectedWorkItems[i];
    if (workItem.lockedUser.length > 0) {
    doRefresh = true;
    workItem.overrideLockStep(function() {
    workItem.abortStep(function() {});
    });
    };
    };
    };
    if (doRefresh) 
    this.getWidget().onRefresh();

    Enable script

    var selectedWorkItems = this.getActionContext("WorkItemReference");
    var selectedWorkItemCount = selectedWorkItems.length;
    var lockedItemSelected = false;
    for (var i=0; i<selectedWorkItemCount; i++) {
    if (selectedWorkItems[i].lockedUser.length > 0)
    lockedItemSelected = true;
    };

    return lockedItemSelected;


    ------------------------------
    DAVE PERMAN
    ------------------------------



  • 3.  RE: Unlock Work item in BAW Case Client

    Posted Sat May 18, 2019 12:52 AM
    Many thanks Dave for the reply. 
    When I try to unlock a work item for the first time, lock icon is still there. And when I open that work item, still I can only view the work item. And when I close that work item, automatically lock gets disappeared and now when I open it, I can perform operations on that work item.
    So my question is that is there a way for the lock icon to disappear and also to able to edit the work item in one go when I click "Unlock"?

    Regards,
    FaisalMeraj

    ------------------------------
    Faisal Meraj
    ------------------------------



  • 4.  RE: Unlock Work item in BAW Case Client

    Posted Fri May 17, 2019 12:52 PM
    Add a Script Action to the In-basket widget

    Execute Script

    var self = this;
    var selectedWorkItems = this.getActionContext("WorkItemReference");
    var selectedWorkItemCount = selectedWorkItems.length;
    var doRefresh = false;
    if (confirm('Are you sure you want to unlock this item?')) {
    for (var i=0; i<selectedWorkItemCount; i++) {
    var workItem = selectedWorkItems[i];
    if (workItem.lockedUser.length > 0) {
    doRefresh = true;
    workItem.overrideLockStep(function() {
    workItem.abortStep(function() {});
    });
    };
    };
    };
    if (doRefresh) 
    this.getWidget().onRefresh();

    Enable Script

    var selectedWorkItems = this.getActionContext("WorkItemReference");
    var selectedWorkItemCount = selectedWorkItems.length;
    var lockedItemSelected = false;
    for (var i=0; i<selectedWorkItemCount; i++) {
    if (selectedWorkItems[i].lockedUser.length > 0)
    lockedItemSelected = true;
    };
    return lockedItemSelected;


    ------------------------------
    DAVE PERMAN
    ------------------------------



  • 5.  RE: Unlock Work item in BAW Case Client

    Posted Wed November 20, 2019 11:01 AM
    Above script will NOT work for more than one workitem at a time. It will only unlock ONE workitem.

    Refresh of inbasket needs to run after all workitems has successfully been unlocked. In order to do so, one need to keep track of unlocked items and when all are finished do a refresh of inbasket. Another way is to use dojo Deferred.

    Below example will refresh the inbasket after all workitems has been unlocked. 

    EXECUTE ---->

    var selectedWorkItems = this.getActionContext("WorkItemReference");
    var selectedWorkItemCount = selectedWorkItems.length;
    var doRefresh = false;
    var completed = 0;
    
    var updateInbasket = dojo.hitch(this, function() {
        if (completed === selectedWorkItemCount) {
            this.broadcastEvent("icm.Refresh", {});
        }
    });
    
    for (var i = 0; i < selectedWorkItemCount; i++) {
        var workItem = selectedWorkItems[i];
        if (workItem.lockedUser.length > 0) {
            workItem.overrideLockStep(dojo.hitch(this, function(wo) {
                wo.abortStep(dojo.hitch(this, function(newWo) {
                    completed = completed + 1;
                    updateInbasket();
                }));
            }));
        };
    };


    ------------------------------
    Svante Reutland
    ------------------------------