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 ?

  • 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

  • Apologies for the late response.

    The -UpdatedBefore is used to limited the search result to a specific timeframe, as the audit we are performing applies to that specific timeframe – and not documents created outside of that time frame. It is a minor issue – we have work arounds for it.

    I am still not able to perform a saved search for folders with ProjectProperties – see image.

  • I think this would be like a between, ie documents created between 1/1/2023 and 2/1/2023.  

  • Hi all, looking for a little help on usings $FIELD$, the saved search is created but the " " or come combination of characters seams to pull an extra LIKE into the outcome of the saved search.  I'm using 23.0.5.0 but seems to the same in earlier builds.

    what's shown in search builder in PW, LIKE '$FIELD$ LIKE '%.dgn' OR $FIELD$ LIKE '%.7z''

    Also, important, is this approach still limited to 255 chars on filters? The outcome I'm looking for is a targeted specific file name list, less wildcards.

    Please correct me if I'm missing something here, seems no matter how I adjust the input to the saved search is not formed correctly.

    NEW-PWLogin

    $FilterperArguments = @{
    SearchName = 'Test4'
    Description = $userFIELD
    FileName = "`$FIELD`$ LIKE '%.dgn' OR `$FIELD`$ LIKE '%.7z'"
    SearchFolder = 'PEDC-0085\'
    SearchSubFolders = $true
    ReplaceExisting = $true
    }

    Add-PWSavedSearch @FilterperArguments -Verbose


    Close-PWConnection

  • Craig,

    $FIELD$ expressions are esoteric functionality.  Until we perfect it, please consider using the Add-PWSavedSearchOrGoup cmdlet to create saved searches in PowerShell with or conditions.   

    To log out of a database, use Undo-PWLogin.  There is no Close-PWConnection cmdlet to my knowledge.

    Hope this helps,

    Mark Weisman | Bentley Systems