Add-PWSavedSearch syntax for $FIELD$ search

According to the change log, support for $FIELD expression was added in PWPS_DAB version 2.1.18.0

using the following powershell code:

$AuditUser = 'thbn'
$SearchField = "`$FIELD(10)`$ = (SELECT DISTINCT o_userno FROM dms_user WHERE o_username in ('$AuditUser'))"
$AuditSkabelon = 'Innovationsprojekter\Test_THBN\'
$SearchFolder = 'Større anlæg\7x\'

Get-PWRichProjects -FolderPath $AuditSkabelon -JustOne | 
Add-PWSavedSearch -SearchName 'CAD-files' -Environment 'Dokument' -DocumentName $SearchField -SearchFolder $SearchFolder -SearchSubFolders -UpdatedAfter 10/10-2020 -ReplaceExisting -Verbose

Gives the following in the search builder:
='$FIELD(10)$ = (SELECT DISTINCT o_userno FROM dms_user WHERE o_username in ('thbn'))'

however, this was the expected search result:
$FIELD(10)$ = (SELECT DISTINCT o_userno FROM dms_user WHERE o_username in ('thbn'))

Do we have any examples for writing the $FIELD expression ?

Parents Reply Children
  • Thanks for the quick response - the code above is now working.
    However, i am facing issues with FIELD-searches like:

    #Search Filtyper
    $FiltyperArguments = @{
      SearchName = 'Filtyper'
      Description = $userFIELD
      FileName = "`$FIELD`$  LIKE '%.zip' OR `$FIELD`$ LIKE '%.7z' OR `$FIELD`$  LIKE '%.rar'" 
      SearchFolder = 'Større anlæg\7x\'
      UpdatedAfter = $AuditDate.AddMonths(-3)
      SearchSubFolders = $true
      ReplaceExisting = $true
    }
    $AuditProjekt | Add-PWSavedSearch @FiltyperArguments -Verbose
    
    Gives the following search value:
    LIKE '$FIELD$  LIKE '%.zip' OR $FIELD$ LIKE '%.7z' OR $FIELD$  LIKE '%.rar''
    
    And not the expected:
    $FIELD$  LIKE '%.zip' OR $FIELD$ LIKE '%.7z' OR $FIELD$  LIKE '%.rar'

    I dont know if it is related, but i in pwps_dab version 2.1.22.0 i am also getting error running the cmdlet Add-PWSavedFolderSearch. Stating that it can not find 'CreateFolderSearch' in 'PWSearchWrapperX64.dll'

    is FIELD-searches also supported in the cmdlet Add-PWSavedFolderSearch ?

  • Reviewing the change log, it states that we added support for $field$ expression to Add-PWSavedSearch.  We will extend that support to other cmdlets as time allows.  We will also look into the trailing single quote issue.   Fixing Add-PWSavedFolderSearch will be our highest priority.

    Thanks,

    Mark Weisman | Bentley Systems

  • Add-PWFolderSavedSearch should now be working in the new 2.1.23.0 release.  It does not as of yet support $field$ expressions.

    Mark Weisman | Bentley Systems

  • Hi

    related to Add-PWFolderSavedSearch

    i am getting the same date when using the parameters -UpdatedAfter and -UpdatedBefore in the same search.

    i am getting "unknown criterion" when using the parameters -ProjectProperties and -ProjectType 

  • As for you first inquiry, please explain why you want to use -UpdatedAfter and -UpdatedBefore in the same search.

    As for you second, I used Example for in the example datasource that you can create with ProjectWise Administrator:

     Add-PWSavedFolderSearch -SearchName "00 Search from PS 8E" -ProjectType General -ProjectProperties @{PROJECT_Project_Name = "PRJ%"} -verbose

    The search worked.  I did create a work area with the Project Type of General and set the Project Name property to PRJ99 before running it.

    To see exactly how to specify the project property names you can use the command 

    Get-PWRichProjectProperties -ProjectType <ProjectType>

    For example

    Get-PWRichProjectProperties -ProjectType General 

    yields 

    PROJECT_Budget
    PROJECT_End_Date
    PROJECT_Owner
    PROJECT_Percent_Complete
    PROJECT_Project_Description
    PROJECT_Project_Location
    PROJECT_Project_Manager
    PROJECT_Project_Name
    PROJECT_Project_Number
    PROJECT_Project_Status
    PROJECT_Start_Date
    ProjectTypeId

    Hope this helps,

    Mark Weisman | Bentley Systems