OOF: how to discard a WorklistShare by it's ID?


Badge +3

I'm using OOF API for my user to manage out of office delegation

I need to allow the user to revoke / discard a WorklistShare previously made for which I've stored the ID.

How to do that?

 

Edit: the Id property is always returning 0, so I can't store it in my data to find the item at a later time. Any workaround that?


5 replies

Badge +6
do you need to discard the out-of-office parameter for a user ? or do you need to discard the delagation for one worklistitem coming from an out-of-office configuration?
Badge +3

icon-quote.gifjan:
do you need to discard the out-of-office parameter for a user ?

Yes I need to discard the whole out-of-office status

icon-quote.gifjan:
or do you need to discard the delagation for one worklistitem coming from an out-of-office configuration?

no, that would apply to the out-of-office status only

Is it possible?

 

Badge +6

To discard the whole out-of-office status:



  • if you are connected with a business user and you want to update your own status, you can do it with the SourceCode.Workflow.Client assembly using the following code: <K2ClientConnectionObject>.SetUserStatus(UserStatusses.Available);
  • if you are connected with an administrator and you want to update the OOO status of someone else. You can do it using the SourceCode.Workflow.Management assembly using the following code: <WorkflowManagementServerObject>.SetUserStatus(@"<LABEL:DOMAINLOGIN>", UserStatusses.Available);

And this will only update the status, the OOO destination rule and the OOO exception rule will always be registered.


I hope this will help you.


 

Badge +3
icon-quote.gifjan:

To discard the whole out-of-office status:



  • if you are connected with a business user and you want to update your own status, you can do it with the SourceCode.Workflow.Client assembly using the following code: <K2ClientConnectionObject>.SetUserStatus(UserStatusses.Available);
  • if you are connected with an administrator and you want to update the OOO status of someone else. You can do it using the SourceCode.Workflow.Management assembly using the following code: <WorkflowManagementServerObject>.SetUserStatus(@"<LABEL:DOMAINLOGIN>", UserStatusses.Available);

And this will only update the status, the OOO destination rule and the OOO exception rule will always be registered.


I hope this will help you.


 



 

Hi Jan, I've tried this one, it will work for the first discarding, but whenever the user need to set another delegation (a new one, in order to replace any previous settings), another problem will occur:

The problem is that the previous worklistshare that was suspended by the first <WorkflowManagementServerObject>.SetUserStatus will be enabled if the user create another delegation.

Here is the code I use to create the worklistshare:

 

public int CreateOutOfOfficeItem(IOutOfOfficeItemCreationData outOfOfficeItemCreationData)
{
    var server = workflowManagementServerAccessor.WorkflowManagementServer;
    var worklistShare =
        new WorklistShare
            {
                ShareType = ShareType.OOF,
                StartDate = outOfOfficeItemCreationData.BeginTimestamp,
                EndDate = outOfOfficeItemCreationData.EndTimestamp
            };
    var workType = new WorkType();
    workType.Destinations.Add(new Destination(outOfOfficeItemCreationData.ToUser, DestinationType.User));
    worklistShare.WorkTypes.Add(workType);
    if (server.ShareWorkList(outOfOfficeItemCreationData.FromUser, worklistShare))
    {
        return worklistShare.ID;
    }
    else
    {
        throw new ApplicationException("WorkflowManagementServer.ShareWorkList returned false");
    }
}

 the first problem is that worklistShare.ID is equal to 0 whatever I do once server.ShareWorkList returned

 then when the users discards it's delegation, the code that I would like:

 

public void DiscardOutOfOfficeItem(string userName, int outOfOfficeItemIdentifier)
{
    var server = workflowManagementServerAccessor.WorkflowManagementServer;
    server.SetUserStatus(userName, UserStatuses.Available);
    //instanciate a dummy worklistshare with the good ID
    //var share = new WorklistShare { ID = outOfOfficeItemIdentifier, UserName = userName };
    //server.UnShare(userName, share);
}

but the commented code won't work because I'm giving 0 which was returned by worklistShare.ID in CreateOutOfOfficeItem

what is the correct way to retrieve the worklistshare identifier when initially created?

what is the correct way to permanently delete a worklistshare by it's identifier?

Badge +3

Here is some information from the support channel:

 

it's not possible to remove an item via it's ID, but it is possible to itterate over the user worklist share item:

here is a sample code that do that:

// Find the User's WorklistShare and remove it.
WorklistShares worklistShares = new WorklistShares();
worklistShares = server.GetCurrentSharingSettings(this.FromUser, ShareType.OOF);
foreach (WorklistShare wlshare in worklistShares)
  server.UnShare(this.FromUser, wlshare);

Reply