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
Parents
  • 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
  • One other quick query. The objects I'm editing have the ISHMetadataBinding data type. I am able to set these values correctly - ie when I replace the Value with a backend ID like /1/2/3/4, it's correctly stored, and I see the correct full text string when I open the publication properties, populated by the metadatabinding. 

    However, when I run this:
    Get-IshMetadataField -IshSession $ishSession -Name "FINFAPRODUCTMETADATA" -Level Version -ValueType Value

    The full text strings are retrieved instead of the IDs, which are what I need. What am I missing here? Changing the ValueType to element or ID doesn't help either. 

    Btw, the reason I need this because I've realized I need to get the existing value first, as multiple values are already in this metadata field in many cases. 

    Thanks for any help!

    emoji
  • Hi Charlie,

    Over the years ISHRemote defaults the -RequestedMetadata to human readable fields. The Id you are looking for is part of the System fields. The most optimal way to add this to the request is in the example below. Where I also gave you some inspiration for the PowerShell read-only PSNoteProperty shortcuts versus lengthy but still supported/correct Get-IshMetadataField usage.

    PS C:\PRIVATE\OneDrive\CODE\ISHRemoteScript> $p=Get-IshPublicationOutput -LogicalId GUID-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -RequestedMetadata (Set-IshRequestedMetadataField -Level Logical -Name FISHMBPRODUCT -ValueType Id)
    
    PS C:\PRIVATE\OneDrive\CODE\ISHRemoteScript> $p[0] | Get-IshMetadataField -Level Logical -Name FISHMBPRODUCT -ValueType Id
    VPRODUCTFAMILYTRIDIONSITES
    PS C:\PRIVATE\OneDrive\CODE\ISHRemoteScript> $p[0] | Get-IshMetadataField -Level Logical -Name FISHMBPRODUCT -ValueType Value
    Tridion Sites (200)
    
    PS C:\PRIVATE\OneDrive\CODE\ISHRemoteScript> $p[0].fishmbproduct_logical_id   
    VPRODUCTFAMILYTRIDIONSITES
    PS C:\PRIVATE\OneDrive\CODE\ISHRemoteScript> $p[0].fishmbproduct_logical_value
    Tridion Sites (200)

    People that want more insights in what fields to use, check Get-IshTypeFieldDefinition or have a look on [Sample \- Descriptive, Basic and All Fields](github.com/.../ReleaseNotes-ISHRemote-0.7.md

    Best wishes,
    Dave

    emoji
  • That's great Dave, thanks for the thorough explanation!

    best,

    Charlie

    emoji
Reply Children
No Data