Skip to main content

I am trying to using K2 Out Of Office API as per this example

http://help.k2.com/onlinehelp/k2blackpearl/devref/4.6.11/default.htm#how_to_set_a_users_out_of_office_status.html

 

But for this line  I get error "The User Does not appear to be managed by the user". I have opened the connection in impersonate mode. So connection user is same as the Sharer.

connection.ShareWorkList(@"K2:DOMAINSharer", worklistshare); 

 If I just use connection.ShareWorkList (workflstshare) , out of office status is set. but task is not assigned to destination user

 

12315iEFEC89F315017FEF.png

HI,

 

For the ShareWorklist method, if you use the overload with 2 input, the first parameter is "ManagedUserName". Not very sure what this is for, but the "Managed" wording usually means the manager account. So, you code should be using the overload with the WorklistShare input only.

 

I tested this code to be working fine in impersonating and setting OOF:

public void SetMyOOFStatus(bool OOF)
{
Console.WriteLine("Executing SetMyOOFStatus");

SCWFC.Connection wfConn = new SCWFC.Connection();
try
{
wfConn.Open(SERVER_NAME);
wfConn.ImpersonateUser("K2:K2Trainhrmgr1");

if (OOF)
{
//Create a share
SCWFC.WorklistShare wlShare = new SCWFC.WorklistShare();
wlShare.ShareType = SCWFC.ShareType.OOF;
wlShare.StartDate = DateTime.Now;
wlShare.EndDate = DateTime.Now.AddDays(1);

//Forward destination
SCWFC.WorkType wtShare = new SCWFC.WorkType("normal");
wtShare.WorklistCriteria.Platform = "ASP";
wtShare.Destinations.Add(new SCWFC.Destination(@"K2:k2trainhradmin1", SCWFC.DestinationType.User));

//Exception destination
//SCWFC.WorkTypeException wtExp = new SCWFC.WorkTypeException("except");
//wtExp.WorklistCriteria.Platform = "ASP";
//wtExp.WorklistCriteria.AddFilterField(SCWFC.WCField.ProcessName, SCWFC.WCCompare.Equal, "ExpenseReview");
//wtExp.Destinations.Add(new SCWFC.Destination(@"K2:K2Trainizmgr1", SCWFC.DestinationType.User));
//wtShare.WorkTypeExceptions.Add(wtExp);

//add to worklistshare
wlShare.WorkTypes.Add(wtShare);
//remove all existing share
wfConn.UnShareAll();
//add WorklistShare
wfConn.ShareWorkList(wlShare);
//set user to be OOF
wfConn.SetUserStatus(SCWFC.UserStatuses.OOF);
}
else
{
wfConn.UnShareAll();
wfConn.SetUserStatus(SCWFC.UserStatuses.Available);
}
}
finally
{
wfConn.Dispose();
}
}

Good luck

JK


Reply