Tridion 2009 - Using Interops - Is there a possibility to add multiple setConditions for the same Name
Asked Answered
K

2

6

Am stuck with small problem.

I want to add multiple setConditions for the same Name that is for PublicationTarget. This is using interops dll.

ListRowFilter rowFilter = mTDSE.CreateListRowFilter();
rowFilter.SetCondition("StartDate", sDate);
rowFilter.SetCondition("EndDate", eDate);
rowFilter.SetCondition("PublicationTarget", pubStgTarget);

For this PublicationTarget, I want to filter with staging & live target and I tried all the ways but no use.

rowFilter.SetCondition("PublicationTarget", pubStgTarget);

Please suggest,
1. Passing xis possible, what is the best way to achieve?

I tried this ways but no luck;-

rowFilter.SetCondition("PublicationTarget", "tcm:0-1-65537"); // Gives only staging
rowFilter.SetCondition("PublicationTarget", "tcm:0-2-65537"); // Gives only Live
rowFilter.SetCondition("PublicationTarget", "tcm:0-1-65537|tcm:0-1-65537"); // No result
rowFilter.SetCondition("PublicationTarget", oPubList); // No result - `oPubList` is a 

List<string>

Kotto answered 15/4, 2012 at 5:44 Comment(1)
Hello Friends, currently I used @Mihai answer #2 to solve the problem. If any one has few more best solutions, please post it.Kotto
J
6

Nope, it is not possible unfortunately. If you want to put a condition on PublicationTarget, it must be to only one PublicationTarget.

However there are 2 workarounds:

  1. Create two RowFilters and set a different PublicationTarget condition in each of them. Then you would issue the query twice (once for each filter). This means you would need to process 2 XML result nodes.

  2. Don't use a PublicationTarget condition when performing the GetListPublishTransactions(). You will then get back an XML element that contains records for all PublicationTargets. In your code, you will filter only those that are of interest to you (e.g. Staging or Live).

I would probably use #2 (unless I know the Publish Queue could potentially return a very large number of records, in which case, I would use #1).

Sample code for #2:

tdse = new TDS.TDSEClass();
tdse.Impersonate(user.Title);
tdse.Initialize();

mgtInfo = tdse.GetManagementInfo();
filter = tdse.CreateListRowFilter();

filter.SetCondition("InfoType", 2); // InProgress
filter.SetCondition("Publication", "tcm:0-23-1");

XmlDocument dom = new XmlDocument();
dom.LoadXml(mgtInfo.GetListPublishTransactions(filter));

XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new NameTable());
namespaceManager.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");

String xPath = String.Format(
    "tcm:ListPublishTransactions/tcm:Item[@PublicationTarget='{0}'] | " +
    "tcm:ListPublishTransactions/tcm:Item[@PublicationTarget='{1}']",
    stagingTcmUri, liveTcmUri);
XmlNodeList nodeList = dom.SelectNodes(xPath, namespaceManager);

foreach (XmlNode node in dom.DocumentElement.ChildNodes) {
    //do your thing
}

Note: double check the XPath expression, I haven't actually tested that bit.

Johst answered 15/4, 2012 at 8:15 Comment(1)
Thanks Mihai. Currently I haven't find any way other than your suggestion #2. I used #2 way, to overcome this problem.Kotto
A
2
Public Function GetListPublishTransactions( Optional ByVal rowFilter As TDS.ListRowFilter ) As String

The method GetListPublishTransactions accepts the following conditions as part of the filter:

  • InfoType (string) (ScheduledForPublish 0, WaitingForPublish 1, InProgress 2, ScheduledForDeployment 3, WaitingForDeployment 4, Failed 5, Success 6) (Omit for all)
  • StartDate (dateTime) Only return items after this date
  • EndDate (dateTime) Only return items before this date
  • User (string) Only return items of for user
  • Publication (string) Only return items for this publication
  • PublicationTarget (string) Only return item for this publication target

It's not possible to have conditions that are used more than once.

You might have to make more than one call to the TOM API to achieve the results you require?

Arredondo answered 15/4, 2012 at 7:58 Comment(6)
No. Am using GetListPublishTransactionsKotto
So Rather than taking one more call, there is no way of representation for passing staging target ID and live target ID to PublicationTargetKotto
I updated to my answer to reflect the fact you are using GetListPublishTransactions. Mihai has confirmed you can only have one PublicationTarget, and has also provided a solution for you.Arredondo
The InfoType cannot be combined -- you either specify one, or omit all (in which case you will get all item types).Crockery
Thanks Mihai, I didn't realise that. I've updated my answer so that it's correct.Arredondo
Thanks Dave. +1 for your answer.Kotto

© 2022 - 2024 — McMap. All rights reserved.