10

I've been playing with a script to get the Application Data on all publications - at the moment I just want to write it out to see what's in there.

I've confirmed several publications have tm: (Translation Manager) App Data but only get null of the Application Data below:

$pubsList = Get-TridionPublications | Select-Object Title, Id, ExtensionData;
$pubsTotal = "Total of " + $myPubs.Count + " Publications";
Write-Output $pubsTotal;
for ($i=0; $i -lt $pubsList.length; $i++) {
    [string]$title = $pubsList[$i].Title;

    if($title.StartsWith("030")){

        $pub = $pubsList[$i];

        $pub.Title;

        $appData = $core.ReadAllApplicationData($pub.Id);

        if ($appData -ne $null) {

            $appData

        }
        else {
            Write-Output "No AppData";
        }
    }
}
4

2 Answers 2

6

On closer investigation of the Publication Object - this exposes the App Data as the ExtensionData as follows:

$pubsList = Get-TridionPublications | Select-Object Title, Id, ExtensionData;

This gives me the Application Data as System Object.

2
  • 1
    Really?! ExtensionData is a special WCF property used to store unrecognized data in (for forward compatibility purposes). The Core Service doesn't return Application Data together with the rest of the object's state, so if your claim is true, somebody must have done a really "creative" implementation of Get-TridionPublications! Mar 10, 2016 at 21:05
  • You're correct Rick - I was a bit quick off the mark there... I have access to what I need through the ReadAllApplicationData method and the ExtensionData isn't the app data 'object' and can be removed from the example above (I'd played with this a little and had tried to access via ExensionData) - I'll spend a little more time cleaning up the code (probably ending up with something more attuned to the appdata companion if time permits Mar 11, 2016 at 1:28
3

I have a function that does it this way:

#Example call:     $appData2 = Get-TridionApplicationData -ObjectId $pubId -ApplicationId "tm:ItemTranslationOptions" -Verbose

here's the guts of the function code

$client = Get-TridionCoreServiceClient
$ad = $client.ReadApplicationData($ObjectId, $ApplicationId)
if ($ad -ne $null)
{
$data = [System.Text.Encoding]::UTF8.GetString($ad.Data)
return $data
}
1
  • This is pretty much what I've done in the modules (on a feature branch at the moment). Some of the app data is using a different encoding, though. I apologize in advance for the future naming conflict :) Mar 11, 2016 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.