Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Move-PWDocumentsToFolder not updating MetaData
    • Sign In

    • State Not Answered
    • +2 person also asked this people also asked this
    • Replies 4 replies
    • Subscribers 67 subscribers
    • Views 831 views
    • Users 0 members are here
    • powershell
    • PWPowerShell
    • pwps_dab
    • ProjectWise PowerShell Modules

    Move-PWDocumentsToFolder not updating MetaData

    Russell Sherman
    Offline Russell Sherman over 4 years ago

    Hi, 

    When using the Move-PWDocumentsToFolder command as below, metadata isn't being copied.

    The document itself is being updated, but the metadata is being kept from the previous version, and not updated with the new version of the document. Is there any way to get it to copy over the new metadata?

     

    Move-PWDocumentsToFolder -InputDocument $doc -TargetFolderPath $path -CreateVersion

    • Sign in to reply
    • Cancel
    • Patrick McCoy
      0 Offline Patrick McCoy Mon, Oct 7 2019 2:11 PM

      I am having the same issue.  Did you ever get an answer to your question or find your own solution?

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Patrick McCoy
      0 Offline Patrick McCoy Mon, Oct 7 2019 2:42 PM in reply to Patrick McCoy

      I am considering this as a workaround, but would like to know whether or not the Bentley team intends for meta-data attributes to be migrated as part of Move-PWDocumentsToFolder or instead needs to be handled separately as shown.

      Assuming a $doc variable already exists...store the attributes for it in a separate variable, so that Update-PWDocumentAttributes can be called afterwards, like this...

      $attributes = $doc.Attributes
      Move-PWDocumentsToFolder -InputDocument $stagingDoc -TargetFolderPath $targetFolder -CreateVersion -DoNotPreserveState
      $newDocs = Get-PWDocumentsBySearch -FolderPath $targetFolder -GetAttributes -JustThisFolder -FileName $doc.FileName
      if ($newDocs -ne $null) {
          $newDoc = $newDocs[0]
          Update-PWDocumentAttributes -InputDocuments $newDoc -Attributes $attributes
      }

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Mon, Oct 7 2019 4:40 PM in reply to Patrick McCoy

      When using the Move-PWDocumentsToFolder cmdlet, the document attributes should be maintained.  Be sure the Environment set on the Target folder is the same as the Source folder.   The document object returned with the cmdlet does not contain the attribute values. You would need to do a Get-PWDocumentsBySearch with the -GetAttributes switch parameter to retrieve them.   Also, are you receiving any error messages?

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Patrick McCoy
      0 Offline Patrick McCoy Tue, Oct 8 2019 9:18 AM in reply to Brian Flaherty

      Brian - thanks for the quick response.  I am indeed moving data where the source and target folders are using different environments and was hoping that attributes which were in common between the two Environments would migrate.  I am not receiving any error messages, and the document does move and is no longer in the source folder afterwards with a new version in the target folder.  

      In my code snippet above, I did realize after posting that I needed to convert the $attributes collection to a hash table and pass that in to the Update-PWDocumentAttributes cmdlet.  So far that seems to be working.

      $attributes = $doc.Attributes
      $attributesHashTable = new-object System.Collections.Hashtable
      for ( $i = 0; $i -lt $attributes.Keys.Length; $i++ ) {
        $attributesHashTable.Add($attributes.Keys[$i],$attributes.Values[$i]);
      }
      Move-PWDocumentsToFolder -InputDocument $stagingDoc -TargetFolderPath $targetFolder -CreateVersion -DoNotPreserveState
      $newDocs = Get-PWDocumentsBySearch -FolderPath $targetFolder -GetAttributes -JustThisFolder -FileName $doc.FileName
      if ($newDocs -ne $null) {
          $newDoc = $newDocs[0]
          Update-PWDocumentAttributes -InputDocuments $newDoc -Attributes $attributesHashTable
      }

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies