Due to essential maintenance, access to Trados cloud will be unavailable on Saturday 30 August from 00:00 to 12:00 UTC.

Updating metadata on the publication version level

Hi, 

I have the following use case I need to implement ASAP. I have several large lists of pubs - the lists contain the GUIDs, the relevant versions, and metadata values that I need to write into a custom metadata field - FINFAPRODUCTMETADATA. 

I've tried investigating IshRemote, but I haven't been able to accomplish this - I've been poring over the help files and any examples I can find here in the dev forum, but to no avail so far. Can this be done with IshRemote cmdlets? Or would it be better/easier to use the API wrapper, eg calls like $mySession.PublicationOutput25.Find? 

Note I don't have any issues with general PS coding, eg the parsing of CSV files and such - the only problem I'm unable to solve is finding the correct way to find the objects in Tridion and then update the metadata field. 

One last thing I was hoping for wrt to this project... I also need to update the metadata of any pub versions that are later than the version I'm targeting. I'm aware that the Version field is a text field - I can write my own comparator for that. I'm just hoping that someone could point me to a working code example for listing all the versions of a publication. 

I'm on Tridion Docs 14sp4, btw, in case that matters. Thanks for any help!

emoji
  • Hi Charles,

    Worth the read is  RE: Using ISHRemote can I filter results where Version is less than or equal to a value? 

     Some code snippets giving the ASAP to unblock as inspiration. I tested them on 15.2.0 but I think they work on 14SP4/14.0.4 as well.

    # As version is a string field, you can do an exact match
    $requestedMetadata = Set-IshMetadataFilterField -Level Version -Name VERSION -FilterOperator Equal -Value '15'
    Get-IshPublicationOutput -LogicalId GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -MetadataFilter $requestedMetadata
    # As you are then updating the version level, it would be a good optimization to do that only once for that version and not for every PublicationOutput below (e.g. English PDF, French PDF, English...)
    
    # Regarding version compare...
    # FISHBRANCHNR is a system field which you need to explicitly get
    # you get ALL of them all the time, if you specify $ishSession.DefaultRequestedMetadata='All'
    $requestedMetadata = (Set-IshRequestedMetadataField -Level Version -Name FISHBRANCHNR)
    $p = Get-IshPublicationOutput -LogicalId GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -RequestedMetadata $requestedMetadata
    
    # to give you an idea of what we retrieved, print the below
    # where the version is just an integer, no branched version, then fishbranchnr is zero... in turn you can use PowerShell -lt operator when cast to an [int]
    $p | Select-Object ishref,version_version_value,fishbranchnr_version_value
    
    # Below is a client-side, so in PowerShell calculation, when there are no branches
    $p | ForEach-Object { 
            if (($_.fishbranchnr_version_value -eq '0') -and ([int]($_.version_version_value) -gt 10)) { Write-Output $_ }
        }
    
    # when there are branches you could consider going 'manual selection' by
    $p | Out-GridView -PassThru
    

    Best wishes,
    Dave

    emoji