Problems with SPListItem.moveTo() method

C

christoph.hanser

Hi!

We're having problems with the method SPListItem.moveTo().
A InfoPath document and stored inside the a SharePoint library.
Afterwards, it is modified using a workflow that runs inside the
Workflow Foundation. This workflow makes some changes inside the
document and stores it in another SharePoint library. There, special
permissions are set to enable different users access to the document.
In the end, the document is moved back into the original library. The
document is not stored immidiatelly inside the original library in
order to set the permissions. The code looks like this:

Dim mst As New MemoryStream
Dim sFilename_1 As String = it.ParentList.Title &
"_Temp/" & sGuid & ".xml"
Dim sFilename_2 As String = it.ParentList.Title & "/" &
sGuid & ".xml"
xmlout.Save(mst)

Dim file As SPFile =
it.ParentList.ParentWeb.Files.Add(sFilename_1, mst, True)

' Berechtigungen initialisieren
Berechtigungen_Initialisieren(file.Item)
' Berechtigung für Rollenmitglieder setzen
Berechtigung_Setzen(file.Item, ds)

file.MoveTo(file.ParentFolder.ParentWeb.Url & "/" &
sFilename_2)

It works really good as long as the administrator of the machine runs
the script. However, when other users run the process, an exception is
thrown when performing the MoveTo() method:

bei Microsoft.SharePoint.Library.SPRequest.MoveUrl(String bstrUrl,
String bstrWebRelOldUrl, String bstrWebRelNewUrl, Int32 grf)
bei Microsoft.SharePoint.SPFile.MoveCopyInternal(String strNewUrl,
Int32 grf)
bei Microsoft.SharePoint.SPFile.MoveTo(String newUrl,
SPMoveOperations flags)
bei Microsoft.SharePoint.SPFile.MoveTo(String newUrl, Boolean
bOverWrite)
bei
eav_workflow_functions.WorkflowFunctions.Einzelantrag_Speichern(SPListItem
it, XmlDocument xml, String guid)

It seems that they do not have the right to overwrite the document.

How can we give all users theses rights?
It does not help to grant them "full access" (Vollzugriff) in
SharePoint.

Also, the idea to run the Update() Methode came to our mind... However,
this works only for list libraries and not for form libraries.
 
C

christoph.hanser

Hi Bruce,

thanks for you help. The difference seems to be that you are using
Encoding.ASCII.GetBytes() instead of the MemoryStream, that we are
using....

My colleague will change his codings and afterwards I will tell you
whether it helped.

Thanks a lot!

Chris
 
C

christoph.hanser

Hi Bruce,

unfortunately, the GebtBytes() "trick" did not solve the problem.
However, we could find out in more detail what the problem is: The
workflow fails to change the InfoPath document after it has been
changed in InfoPath by another person.

The workflow is like this:

First, the InfoPath document is written by a user and published in
SharePoint.
Second, this document is taken by the workflow and new forms are
created and stored in SharePoint.
Third, a person (the user's chief) approves these new forms. His
decision is stored in the form.
Fourth, the workflow takes these forms.

Now, the workflow can read the form, but it can't make any changes to
it.

We granted the document's access rights so that the user, that runs IIS
(and, thus, the Workflow Foundation, we assume), always gets full
access to each document.

However, the problem is still there, and documents which have been
changed by some other user in InfoPath can't be overwritten by the
Workflow Foundation.

Does anyone have a clue about this?
Or knows how the rights have to be granted exactly?

Thanks!
Christoph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top