#PowerShell, #PowerWiseScripting, #ProjectWise, PWPS_DAB

HowTo: Create Documents with Document Coding

Be sure to check out my Scripting4Crypto initiative. It’s a fun way to get into using cryptocurrencies all while getting your PowerShell needs met.

In this post, we will step through the process of creating documents using Document Coding.  We will look at setting up Document Coding for a ProjectWise Environment, and creating documents within ProjectWise Explorer. Then we will create documents using PowerShell.

We will be using the following cmdlets to accomplish this task. All of the ProjectWise related cmdlets are available using the PWPS_DAB module. At the time of this post, I am using version 1.12.10.0. Take a look at the help for each of the cmdlets to become familiar with their functionality, available parameters, etc.

  • Get-PWFolders
  • Add-PWDocumentsWithCode

Define Document Code…

Here we will set up the Document Code for an Environment within ProjectWise Administrator.

From within ProjectWise Administrator:

  • Right mouse-click on the Environment to setup Document Coding for.
  • Select Define Document Code…
    • The Document Code Definition Wizard is displayed.
  • Click Next
    • Choosing document code type page displays.
  • Toggle Yes, I would like to define serial number for this environment.
  • Click Next
    • Defining serial number context page displays.
  • Double-click on any attributes to be used in the document coding.
  • Click Next
    • Defining serial number page displays.
  • Select the attribute to be used for the serial number.
  • Click Next
    • Selecting other code parts page displays.
  • Double-click on any other attributes to include in the document coding.
  • Click Next
    • Defining placeholder page displays.
  • Select the attribute to be used to store the generated document code.
  • Click Next
    • Defining additional attributes page displays.
  • Double-click any attributes to include in the document code process.
  • Click Next
    • Defining document code formatting page displays.
  • Ensure the document code attributes are in the correct order and the options are set as desired.
  • Click Next
    • Finishing Document Code Definition Wizard page displays.
  • Click Finish

Creating Documents within ProjectWise Explorer

Within ProjectWise Explorer, set the Environment for a folder to use the environment the document coding has been defined for.

In this example, the Environment name is “MyEnvironment”.

pwfolder

  • Select the folder to create documents in.
  • Select New > Advanced Wizard… from the Document menu.
    • Advanced Document Creation Wizard starts.
    • The Select a Template page displays.
  • Select a template
    • In this example I am selecting a template from recently used templates.
  • Click Next
    • The Define Document Code page displays.
  • Enter values in each of the available fields within the Document Unique Identifier section of the page.
    • In this example I set the following:
      • doccodesection1 = “XXXXXX”
      • doccodesection2 = “TEST”
      • sequence = 1
        • Click Generate to populate with next avaible sequence value.
  • Click Next
    • The Document Properties page displays.
  • Update the document name and description as desired.
  • Click Next
    • The Define Document Attributes page displays
  • Update any attributes as desired.
  • Click Next
    • Finishes the document creation process.

Creating Documents using PowerShell

Now we will create a couple of documents using PowerShell.

From within PowerShell ISE, log into a ProjectWise datasource.

Select the folder to create documents in using the Get-PWFolders cmdlet.

# ProjectWise folder object to be used in document creation.
$pwFolder = Get-PWFolders -FolderID 1606 -JustOne

Next, we will populate the attributes associated with the document code definition as we did within ProjectWise Explorer. However, we do not need to populate the sequence value as the cmdlet will determine the next available sequence value.

# Hashtable containing attribute name and value combinations.
$pwDocCodeAttributes = @{
    'doccodesection1' = 'XXXXXX'
    'doccodesection2' = 'TEST' 
}

Create two new documents using the Add-PWDocumentsWithCode cmdlet by specifying the NumberOfDocuments equal to 2.

# Splat containing parameter and value combinations.
$Splat_DocCodeAttributes = @{
    InputFolder = $pwFolder
    Attributes = $pwDocCodeAttributes
    NumberOfDocuments = 2
}
$pwDocs = Add-PWDocumentsWithCode @Splat_DocCodeAttributes -Verbose

The following shows the results of the document creation process. Notice two additional documents were created and the sequence number was incremented appropriately.

pwe_result


Experiment with it and have fun.

Hopefully, you find this useful. Please let me know if you have any questions or comments.  If you like this post, please click the Like button at the bottom of the page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.