1

I already got solution like getting all the Target Types for all Publications and then filtering the Target Types based on particular Publication (like checking all Target Type is being used in which Publications). So i am getting the correct result like all available of Target Types for particular Publication.

I am using the following code:

List<TridionItem> pubTargetList = new List<TridionItem>();
var pubTargets = client.GetClient.GetSystemWideList(new PublicationTargetsFilterData());
foreach (PublicationTargetData pubTargetdata in pubTargets)
{

    PublicationTargetData target = (PublicationTargetData)client.GetClient.Read(pubTargetdata.Id, new ReadOptions());                   
    LinkToPublicationData[] pubDataItems = target.Publications;

    foreach (LinkToPublicationData publicationData in pubDataItems)
    {
        if (publicationData.IdRef == publicationId)
        {
            pubTargetList.Add(new TridionItem()
            {
                Id = pubTargetdata.Id,
                Name = pubTargetdata.Title
            });
        }
    }
}

But I think there might be better way to retrieve the Target Types based on Publication directly. Any further information will be very helpful.

Thanks, Debabrata

2 Answers 2

0

I'm afraid there is no better (or shorter) way than your mentioned solution.

One would probably, expecting a property like PublicaitonData.Targets.

I think API designers have purposely decided not to implement this as it would lead to performance issues, especially in the Core service API.

If the goal is to retrieve the targets data faster, I would cache the results of the above implementation. For example, at application startup, retrieve all targets data and store it in a List/Set for all Publications or the required one(for any subsequent retrieval).

1
  • Thanks @Shahid Eqamuddin for your useful information. But One concern in this approach like first time it is checking all publication for each target type so taking longer time to get the information for target type for specific publication. But as you mentioned, we can follow the caching mechanism to improve the performance for consecutive request after first request.
    – Debabrata
    Jul 1, 2019 at 12:22
1

You will need to do a SystemWideList with a TargetTypesFilterData filter, with the ForRepository property set.

Here is an example in PowerShell:

$client = Get-TridionCoreServiceClient

$filter = New-Object Tridion.ContentManager.CoreService.Client.TargetTypesFilterData
$linkToPublication = New-Object Tridion.ContentManager.CoreService.Client.LinkToRepositoryData
$linkToPublication.IdRef = 'tcm:0-6-1'
$filter.ForRepository = $linkToPublication

$client.GetSystemWideList($filter)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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