We have folder templates that are used by workflow to copy specific sets of folders into new customer folders. Those folders need explicit security set. We were anticipating the functionality of the client to work the same in workflow. Namely, that when you copy a folder in the client it keeps the explicit access rights defined on the folder. However, a Move Entry (copy) activity in workflow seems to skip the access rights when copying. How can I have workflow copy the entry access rights just like when manually copying in the client?
Question
Question
Can workflow keep the explicit folder access rights when copying folders within the same repository?
Answer
You can copy the rights entry by entry using SDK script. Below is a sample workflow that takes the Copy Destination folder as is starting entry and then copies the Source and loops through each copied entry and copies the Entry Access form the original.
Protected Overrides Sub Execute() 'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session Dim sMsg as String = "" Try Dim iSourceID as Integer ' Get Source ID from token If Integer.TryParse(TokenReplace("%(ForEachValue_Current Value)"), iSourceID) then ' Here for Testing and should be commented out for production use SetToken("IDValue", iSourceID.ToString) ' The line above allows us to track and ensure the script is getting the correct values ' We can use a Track Tokens activity to verify during testing but remove for production ' Get Source and Destination Root paths for later use Dim sOriginalParent As string = TokenReplace("%(SourcePath)") Dim sDestinationParent As String = TokenReplace("%(NewCopyPath)") ' Get the Source Entry to copy Access Control Using SourceEntry As EntryInfo = Entry.GetEntryInfo(iSourceID, RASession) ' Next 4 lines are for testing and should be commented out for production use Dim SourceFullPath As String = SourceEntry.Path Dim DestFullPath As String = SourceEntry.Path.Replace(sOriginalParent, sDestinationParent) SetToken("SourcePath", SourceFullPath) SetToken("DestinationPath", DestFullPath) ' The 4 lines above allow us to track and ensure the script is getting the correct values ' We can use a Track Tokens activity to verify during testing but remove for production ' Get the Destination Entry to apply Access Control Using DestinationEntry As EntryInfo = Entry.GetEntryInfo(SourceEntry.Path.Replace(sOriginalParent, sDestinationParent), RASession) ' Copy Source Access Control to Destination DestinationEntry.SetAccessControl(SourceEntry.GetAccessControl) ' Save Changes to Destination DestinationEntry.Save End Using End Using Else ' Set error message if unable to get Source ID from token sMsg = "Invalid Source ID" End If Catch ex As Exception ' Set error message sMsg = ex.Message End Try ' Report any errors SetToken("ScriptError", sMsg) End Sub
Replies
I don't know how many folder templates you have but could you recreate each template in a workflow and then have your original workflow with the copy folder step just invoke the workflow for the correct template? This is how I build all my folder structures so when I move the process solution between my Dev, Test, and Production environments I don't have to reset permissions on the folders each step. I just promote the workflow to each environment and run the workflow to create the needed folder structure and set permissions.
Thanks Jennifer, we were preparing to use workflow to create all those explicit permissions if there's no way to copy them in workflow. I had just hoped we could do it with a copy, since the folder tree we're copying has a bunch of explicit permissions and makes for a large workflow to set all those permissions.
You can copy the rights entry by entry using SDK script. Below is a sample workflow that takes the Copy Destination folder as is starting entry and then copies the Source and loops through each copied entry and copies the Entry Access form the original.
Protected Overrides Sub Execute() 'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session Dim sMsg as String = "" Try Dim iSourceID as Integer ' Get Source ID from token If Integer.TryParse(TokenReplace("%(ForEachValue_Current Value)"), iSourceID) then ' Here for Testing and should be commented out for production use SetToken("IDValue", iSourceID.ToString) ' The line above allows us to track and ensure the script is getting the correct values ' We can use a Track Tokens activity to verify during testing but remove for production ' Get Source and Destination Root paths for later use Dim sOriginalParent As string = TokenReplace("%(SourcePath)") Dim sDestinationParent As String = TokenReplace("%(NewCopyPath)") ' Get the Source Entry to copy Access Control Using SourceEntry As EntryInfo = Entry.GetEntryInfo(iSourceID, RASession) ' Next 4 lines are for testing and should be commented out for production use Dim SourceFullPath As String = SourceEntry.Path Dim DestFullPath As String = SourceEntry.Path.Replace(sOriginalParent, sDestinationParent) SetToken("SourcePath", SourceFullPath) SetToken("DestinationPath", DestFullPath) ' The 4 lines above allow us to track and ensure the script is getting the correct values ' We can use a Track Tokens activity to verify during testing but remove for production ' Get the Destination Entry to apply Access Control Using DestinationEntry As EntryInfo = Entry.GetEntryInfo(SourceEntry.Path.Replace(sOriginalParent, sDestinationParent), RASession) ' Copy Source Access Control to Destination DestinationEntry.SetAccessControl(SourceEntry.GetAccessControl) ' Save Changes to Destination DestinationEntry.Save End Using End Using Else ' Set error message if unable to get Source ID from token sMsg = "Invalid Source ID" End If Catch ex As Exception ' Set error message sMsg = ex.Message End Try ' Report any errors SetToken("ScriptError", sMsg) End Sub
I am just looking at this question and wondering if this has gotten easier in the past 8 years since this question was first answered?
I am trying to create a group of folders that has certain permissions on them and create a workflow that will copy them with their permissions to the new location when the workflow runs.
Let me know.
Thanks!