How do I find out the status of the latest version of an object using ISHRemote?

Hello,

I'm trying to use ISHRemote to find out the latest version of an object in en-us language, as well as the status of that version in en-us. I can get hold of the object like this:

$thisObject = Get-IshDocumentObj -IshSession $ishSession -LogicalId $objectID

And then I can do this to get all the version numbers of all languages:

$objectVersion = Get-IshMetadataField -IshSession $ishSession -IshObject $thisObject -ValueType Value -Level Version -Name VERSION

And in a similar way, I can get all statuses of all languages. But how do I combine these queries to get the information I need? Is Get-IshMetadataField  even the correct cmdlet, or should I be using something else?

Simo

Parents
  • Hi Simo,

    Since version 0.7 the explicit -IshSession parameter is no longer required, although it is good practice to be explicit :-) (https://github.com/sdl/ISHRemote/releases/tag/v0.7)

    On my reference system using ISHRemote v0.10 the default rendering of your first cmdlet looks like below including the status (fstatus property)

    ISHType          Title                                    LogicalId                                 Version Lang  Res   Status             ModifiedBy          ModifiedOn    
    -------          -----                                    ---------                                 ------- ----  ---   ------             ----------          ----------    
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 1       en-us       Released           author1                              
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 2       en-us       Released           author2                          
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 2       ja-jp       Translation app... ddemeyer                          
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 3       en-us       Released           author2                          
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 3       ja-jp       Translation app... author2                          
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 3       zh-cn       Translation app... author2                          
    ISHModule        Something User Guide                     GUID-4C413EBB-262A-462E-89F7-030D3E4C2548 4       en-us       Released           author2     

    Assuming that you are looking for version 4 in en-us as a hit in this example data then the below could work for you

    # First of all, you need the latest ISHRemote (at the time of writing 0.10), see github.com/.../ISHRemote how to update
    #
    # Option 1; probably fastest using server-side filter to only retrieve you requested language for your specified LogicalId/ObjectID
    $metadataFilter = Set-IshMetadataFilterField -Level Lng -Name DOC-LANGUAGE -FilterOperator Equal -Value en-US
    $thisObject = Get-IshDocumentObj -LogicalId $objectID -MetadataFilter $metadataFilter | 
                  Sort-Object -Descending -Property version_version_value |
                  Select-Object -First 1
    # Risk here is that Sort-Object sorts alphabetically, so version 1, 10, 11, 2... you expect numerically, let 
    # alone sorting branches like 11.2.2 is higher than 11.1.1
    
    
    # Option 2; the CMS API allows it, but ISHRemote doesn't offer it directly, indirectly however... :-)
    # The most accurate as the filtering happens server-side for the version 
    # and language, however the filtering on the right LogicalId/ObjectID happens client side so in 
    # practice you are retrieving full folder content and then selecting the right one which could affect performance
    $folderPath = Get-IshDocumentObjFolderLocation -LogicalId $objectID
    $thisObject = Get-IshFolderContent -FolderPath $folderPath -VersionFilter "latest" -LanguagesFilter "en-US" | 
                  Where-Object -Property IshRef -EQ -Value $objectID
    
    
    # Option 3; to come up with an idea to improve ISHRemote by some cmdlet overload and log it on GitHub

    Happy Friday!

  • Hello Dave,

    I tried your option 1, and it worked. Now I can get the status info I wanted like this:

    $objectStatus =  Get-IshMetadataField -IshObject $thisObject -ValueType Value -Level Lng -Name FSTATUS

    Thanks a lot!

    Simo

Reply Children
No Data