ERROR: "User DuncanJ cannot be found"

  • 30 March 2005
  • 7 replies
  • 23 views

Badge +3

I have an activity with DuncanJ set as the destination user.
I added him to the destination rule by dragging him accross.
The process initiates and the first user completes their activity.
Then according to Reports, DuncanJ is assigned the next activity, but it errors out in the error log with "User DuncanJ cannot be found".

Has anyone ever seen this?
Any ideas?

Thanks
C


7 replies

Badge +3
I tried changing the user to JamesL. No luck.
I tried changing adding DuncanJ back together with JamesL. No luck.
So...
If anyone cares to take a look at the "Repair Error" dump and give me any thoughts you may have, I would appreciate it.

Thanks
C



Sub Main(K2 as SourceCode.KO.ClientEventContext)
'Create the ActivityInstance of the InfoPath Document - Do not Remove this Code - InfoPath Web service relies on this data
K2.ActivityInstanceDestination.XmlFields("K2InfoPathSchema").Value = K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value
SendDocURL(K2)
End Sub
Public Function SendDocURL(K2 as SourceCode.KO.ClientEventContext) As String
Dim K2SPUtil As New SourceCode.K2SPUtilities.SPSUtilities()
Dim strXMLString As String
Dim TempPath As String = ""
Dim FileURL As String
Dim FileName As String = ""
Dim i,j As Integer
Dim strView As String = "Phase2Approval"
Dim strProcessName As String = K2.ProcessInstance.Process.Name
Dim strActivityName As String = K2.ActivityInstanceDestination.ActivityInstance.Activity.Name
Dim oXMLFields As SourceCode.KO.XmlFields = K2.ProcessInstance.XmlFields
Dim sDestUserFQN As String = K2.ActivityInstanceDestination.User.FQN
Dim sDestUserManagerFQN As String = K2.ActivityInstanceDestination.User.Manager
If FileName = "" Then
FileName = K2.Event.Name & "." & K2.SerialNumber.Replace(",","_") & ".xml"
Else
If Right(FileName,4).ToLower <> ".xml" Then
FileName = FileName & ".xml"
End If
End If
For i = 0 To oXMLFields.Count - 1
If oXMLFields.Item(i).Name = "K2InfoPathSchema" Then
If(IsNothing(K2.ProcessInstance.XmlFields.Item(i).Value))OrElse(K2.ProcessInstance.XmlFields.Item(i).Value.ToString().Trim = "") then
If K2.ProcessInstance.DataFields("K2DisableSubmitButton").Value = True Then
strXMLString = K2SPUtil.UpdateDocumentWithView(K2.ProcessInstance.XmlFields.Item(i).MetaData, strView,K2.SerialNumber, K2.ProcessInstance.ID,"",sDestUserFQN & "," & sDestUserManagerFQN,K2.ProcessInstance.DataFields("K2ShowViewFlowLink").Value,K2.ProcessInstance.DataFields("K2UseCachedViewFlowData").Value)
Else
strXMLString = K2SPUtil.UpdateDocumentWithView(K2.ProcessInstance.XmlFields.Item(i).MetaData, strView,K2.SerialNumber, K2.ProcessInstance.ID,"","",K2.ProcessInstance.DataFields("K2ShowViewFlowLink").Value,K2.ProcessInstance.DataFields("K2UseCachedViewFlowData").Value)
End If
Else
If K2.ProcessInstance.DataFields("K2DisableSubmitButton").Value = True Then
strXMLString = K2SPUtil.UpdateDocumentWithView(K2.ProcessInstance.XmlFields.Item(i).Value, strView,K2.SerialNumber, K2.ProcessInstance.ID,"",sDestUserFQN & "," & sDestUserManagerFQN,K2.ProcessInstance.DataFields("K2ShowViewFlowLink").Value,K2.ProcessInstance.DataFields("K2UseCachedViewFlowData").Value)
Else
strXMLString = K2SPUtil.UpdateDocumentWithView(K2.ProcessInstance.XmlFields.Item(i).Value, strView,K2.SerialNumber, K2.ProcessInstance.ID,"","",K2.ProcessInstance.DataFields("K2ShowViewFlowLink").Value,K2.ProcessInstance.DataFields("K2UseCachedViewFlowData").Value)
End If
End If
For j = 0 To K2.ActivityInstanceDestination.XmlFields.Count
If K2.ActivityInstanceDestination.XmlFields.Item(j).Name = "K2InfoPathSchema" Then
K2.ActivityInstanceDestination.XmlFields.Item(j).Value = strXMLString
exit for
End If
Next
Exit For
End If
Next
'Begin SharePoint Integration********
Dim spsList As New K2SPSList()
Dim strWorkSpaceURL As String
Dim strDocLib As String
Dim strWorkSpaceName As String = ""
Dim strServerURL as string
Dim strPartServerURL as string
Dim oByte() As Byte
If strXMLString.Trim.Length = 0 Then
Exit Function
Else
'Read into byte array
Dim oTextEncoder As New System.Text.UTF8Encoding
oByte = oTextEncoder.GetBytes(strXMLString)
oTextEncoder = Nothing
End If
strServerURL = K2.ProcessInstance.DataFields("K2SharePointURL").MetaData & "/_vti_bin/K2SpsList.asmx"
strPartServerURL = K2.ProcessInstance.DataFields("K2SharePointURL").MetaData
If strServerURL.Trim <> "" then
spsList.URL = strServerURL
End If
spsList.Credentials = K2SPUtil.GetCredentials(strPartServerURL)
Try
If K2.ProcessInstance.DataFields.Item("K2CreateNewWS").Value = True then
If K2.ProcessInstance.DataFields.Item("K2DWSName").MetaData.Trim.Length > 0 then
strWorkSpaceName = K2.ProcessInstance.DataFields.Item("K2DWSName").MetaData & "/" & K2.ProcessInstance.DataFields.Item("K2DWSName").Value
Else
strWorkSpaceName = K2.ProcessInstance.DataFields.Item("K2DWSName").Value
End If
Else
strWorkSpaceName = K2.ProcessInstance.DataFields.Item("K2DWSName").Value
End If
strWorkSpaceURL = K2.ProcessInstance.DataFields("K2DWSPath").Value
Catch
strWorkSpaceName = ""
strWorkSpaceURL = ""
End Try
strDocLib = K2.ActivityInstanceDestination.DataFields.Item("DocFolder").Value
If right(strWorkSpaceURL,1) <> "/" Then
strWorkSpaceURL += "/"
End If
If right(strDocLib ,1) <> "/" Then
strDocLib += "/"
End If
Dim ret As Boolean, errMess As String
FileURL = strWorkSpaceURL + strDocLib + FileName
If spsList.UploadDocumentFromUrl(strWorkSpaceName, FileURL, oByte, True, errMess) then
'Update the Activity Fields for Cleanup purposes
K2.ActivityInstanceDestination.DataFields("SPFileURL").Value = FileURL
K2.ActivityInstanceDestination.DataFields("SPFileSite").Value = strWorkSpaceName
Else
Throw New System.Exception(errMess)
End If
oByte = Nothing
'Begin Add to SharePoint TaskList********
Dim strErrMess As String
Dim IntUserId As Integer
Dim intListItemID As Integer
Dim strPriority As String = "(1) High"
Dim strTaskListName As String = "K2 Tasks"
Dim UserName As String = K2.ActivityInstanceDestination.User.FQN()
Dim strTaskDescription As String = ""
strTaskDescription = strTaskDescription & "GIR Phase 2 for "
strTaskDescription = strTaskDescription & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:FacilityName")
strTaskDescription = strTaskDescription & " pending."
If spsList.GetUserId(K2.ActivityInstanceDestination.DataFields("TaskListSite").Value, UserName, IntUserId, strErrMess) Then
Dim strUser As String
Dim strErrorMessage As String
If spsList.CreateListItem(K2.ActivityInstanceDestination.DataFields("TaskListSite").Value, strTaskListName, K2SPUtil.CreateTaskXML(strTaskDescription, strWorkSpaceURL, FileURL, strPriority, intUserID,"",strProcessName,strActivityName),intListItemID, strErrorMessage) Then
K2.ActivityInstanceDestination.DataFields("K2TaskItemIDs").Value = intListItemID
Else
Throw New System.Exception(strErrorMessage)
End If
Else
Throw New System.Exception(strErrMess)
End If
'End Add to SharePoint TaskList********
'End SharePoint Integration********
FileURL = System.Web.HttpUtility.UrlPathEncode(FileURL)
K2.AddWorklist("ASP",FileURL)
SMTPFunction(K2,FileURL,"InfoPath Document URL")
End Function
Function SMTPFunction(Byval K2 as ClientEventContext,ByVal strUrl as String,ByVal strClientURL as string)
Dim objMsg As New System.Web.Mail.MailMessage()
Dim objAttachment As System.Web.Mail.MailAttachment
Dim objSender As System.Web.Mail.SmtpMail
Dim strFrom as String
Dim strEmail As String
Dim strSubject As String
Dim strBody As String
objSender.SmtpServer = SourceCode.K2Utilities.GeneralMod.GetDefaultSMTPServer()
strFrom = "IDEM@k2mega.local"
strEmail = K2.ActivityInstanceDestination.User.Email
If IsNothing(strEmail) OrElse strEmail.Trim().Length = 0 then
Throw New System.Exception("No Email Address was supplied, please rectify and try again.")
End If
strSubject = strSubject & "GIR Phase 2 for "
strSubject = strSubject & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:FacilityName")
strSubject = strSubject & " pending."
strBody = strBody & "Dear "
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ActivityInstanceDestination.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:_K2/my:DestinationUser")
strBody = strBody & ","
strBody = strBody & System.Environment.NewLine
strBody = strBody & System.Environment.NewLine
strBody = strBody & "A GIR for "
strBody = strBody & SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:FacilityName")
strBody = strBody & " is awaiting Phase 2 Approval."
strBody = strBody & System.Environment.NewLine
strBody = strBody & System.Environment.NewLine
strBody = strBody & "InfoPath Form: "
strBody = strBody & System.Environment.NewLine
strBody = strBody & "SharePoint Task: "
strBody = strBody & K2.ActivityInstanceDestination.DataFields("TaskListSite").Value
strBody = strBody & System.Environment.NewLine
strBody = strBody & System.Environment.NewLine
strBody = strBody & "Sincerely,"
strBody = strBody & System.Environment.NewLine
strBody = strBody & "IDEM"
objMsg.From = strFrom
objMsg.To = strEmail
If strClientURL.Trim.Length > 0 And Instr(strBody,"[" & strClientURL & "]") > 0 then
strBody = strBody.Replace("[" & strClientURL & "]", strURL)
Else
strBody += System.Environment.NewLine & System.Environment.NewLine & "HTTP InfoPath URL: " & strUrl
End If
objMsg.Subject = strSubject
objMsg.Body = strBody
objSender.Send(objMsg)
End Function
Badge +3
One more thing that probably isn't relevant, but should be mentioned for completeness...

In this step I'm trying to do a loop back i.e. the user can set a dropdownlist to "Approved" and it moves on to step 3, or the user can set the dropdownlist to "Reprocess" which would send the activity back to step 1.
The default value is "Not Approved".

The reason I say its not relevant is because I took the loopback out and tested with the same failed result, but you never know.

Thanks
C
Badge +3
My appologies.
I left out one last item.
The field used to be a boolean field in the InfoPath form that drives the activity.
I changed it to String, changed the dropdown values and defaults, refreshed the InfoPath info from K2Studio but still nothing.
Could the change in InfoPath have caused the problem?

Thanks
C
Badge +3
FYI, I just tried recreating the acitivity from scratch, re-Exporting, rebinding and recompiling the start form etc.
Nothing seems to work.
Badge +3
In case someone searches the board for answers, the solution to my problem was based in SharePoint.
Both DuncanJ and JamesL did not have EXPLICIT permissions to the WSS workspace site that was hosting the InfoPath forms.
I say EXPLICIT because I gave K2MEGADOMAIN USERS contributor access, but it appears that the K2 WorkList was looking for explicit permissions so once I added DuncanJ to the site, he was able to receive his items in his WorkList.

Thanks
C
Badge +8
If you add a group as a user of a SharePoint site, SharePoint handles it kinda wierd.
It does not add an individual 'user record' to it's database for each user in the group when you add the group, instead, it creates an individual 'user record' only when a user opens that site. You can verify this behavior with adding a listbox as metadata for a library and selecting information from site...user information. Add a group to the site...investigate the values in the drop-down...open the site as another user and the once again investigate the values in the drop-down.

So..to get back to DuncanJ, you don't have to add him explicitly, just open the site as DuncanJ before the K2.net server tries to add a task to the Task List for DuncanJ.

It does make you feel a bit uneasy leavings things to chance like this doesn't it? So I would also add them explicitly to remove that little shaddow of doubt. :wink:
Badge +3
OK, that makes sense.
So it seems that K2 plugs into the same data source that the Members web part in SharePoint uses.
Thanks for reading and replying to this long thread.

Thanks
C
"It was said that you would destroy the Sith, not join them!" - Obi-Wan Kenobi

Reply