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 ?
Thank you for bringing this to our attention. Your field syntax is correct. This should work better next release.
Mark Weisman | Bentley Systems
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 ?
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,
Thanks for the reply, one last question. Can the saved search be added to? Meaning after creation, can an 'Or' Group be added in a second step? Also, Close-PWConnection is listed as a base function in pwps from what I see.
I would recommend using the Undo-PWLogin cmdlet. It's included in the pwps_dab module, which can be run in 64 bit mode.
You can use the 'Add-PWSavedSearchOrGroup' cmdlet to add an 'OR' to your saved search.
The PWPS module will only work in 32-bit mode. PWPS_DAB works in 32 bit mode and 64 bit mode. If you use both, mix cmdlets carefully. For instance you do no want to login in with a cmdlet from the PWPS_DAB module and log out with a cmdlet from the PWPS module.
Thank you all, understood.