How to remove a LOV from content using ISHRemote

Question: Is there a way to use ISHRemote to remove LOV values from content in TDX?

I'm using PowerShell to automate publishing in TDX 14. I have a PS script to allow users to create named "collections" of publications, and then perform some action on them (generate PDFs, download existing PDFs, enable/disable draft comments, etc.).

The collection names are values in LOV that users add to a field in the publication properties, and then are referenced by the PS script.

I'd like to use the ISHRemote module to manipulate the value in LOV (so that users can automate removing collection names, for example).

I know that the Remove-IshLovValue cmd-let can be used to delete values from an LOV. But this only works if the value is not actively in use in content.

So what I need is to first return a list of all publications that have the selected LOV value in their "collection name" field, remove the value from these fields in each publication, THEN run Remove-IshLovValue to delete the collection name/value.

Is this possible?

emoji
Parents
  • Hi Tyrone,

    In the end a CMS, compared to a file system, offers referentical integrity. If I may rephrase you are looking for a way to identify which Publication(Outputs) are using certain List-of-Values entries so you can do some house keeping. There is no recursive, remove all usage and the final entry. This cascade needs to be handled separately, below some pseudo code.

    As a nice to know, the User Interfaces in more recent versions of Tridion Docs, respect the Active flag on List-of-Values. When a value is marked as 'inactive' it means, it stil is a good value, you can still submit it. It however no longer shows up in User Interfaces as they are considered outdated or no longer preferred values. Similarly, users that left the company can be marked as Inactive, but they were still the Author at the time (so a valid value).

    I'm going to assume that your List-of-Values entry is not returning huge result sets. So I will use the Find-IshPublicationOutput, otherwise you need to check the help examples of Get-IshFolder.

    PS C:\> # Remember that your type and setup field is
    Get-IshTypeFieldDefinition | Out-GridView
    
    PS C:\> # as an example, system field FISHPUBISDEPLOYED is linked to system LOV BOOLEAN
    # LOV BOOLEAN, as you can imagine, as two element values which you can see by 
    # IshRef column, so FALSE and TRUE, are the stable/non-user-interface values to filter on.
    Get-IshLovValue -LovId BOOLEAN
    
    LovId             IshRef                        Label                         Active
    -----             ------                        -----                         ------
    BOOLEAN           FALSE                         No                            Yes   
    BOOLEAN           TRUE                          Yes                           Yes   
    
    
    
    PS C:\> # Either use Equal FilterOperator, or use In FilterOperator (so comma-space like 'FALSE, TRUE')
    $publicationOutputs = Find-IshPublicationOutput -MetadataFilter (Set-IshMetadataFilterField -Level Lng -Name FISHPUBISDEPLOYED -FilterOperator In -ValueType Element -Value 'FALSE')
    
    ISHType          Title                                    LogicalId                                 Version Lang  OutputFormat  Status             Publisher           PublishStartDat
                                                                                                                                                                           e              
    -------          -----                                    ---------                                 ------- ----  ------------  ------             ---------           ---------------

    Next up is Set-IShPublicationOutput, and handle every hit in the $publicationOutputs variable

    $publicationOutputs | ForEach-Object -Process { 
          $oldValue = $_.fishpubisdeployed_lng_element
          $newValue = $oldValue.Replace('FALSE','TRUE')
          Write-Host ("Replacing old["+$oldValue+"] with new["+$newValue+"]")
          # $_ | Set-IshPublicationOutput -Metadata (Set-IshMetadataField -Level Lng -Name FISHPUBISDEPLOYED -ValueType Element -Value $newValue)
        }

    And now, when your List-of-Value entry is no longer used, a Remove-IShLovValue will succeed.

    To be clear "FISHPUBISDEPLOYED" is a bogus example, please adapt to your setup before executing.

    Hopefully gets you going,
    Dave

    emoji
Reply Children
No Data