Publish Transaction Information Type Mismatch Error

295 views Asked by At

Using Tridion 2009, SP1, hence the old COM+ TOM API. I'm trying to get information of a PublishTransaction but getting an error each time I call the PublishTransaction.Information property.

Here is my code:

try
{
    var pubTrans = (PublishTransaction)tdse.GetObject("tcm:0-166535-66560",
                                                      EnumOpenMode.OpenModeView);
    Console.WriteLine("transaction id=" + pubTrans.ID);
    Console.WriteLine("transaction itemtype=" + pubTrans.itemType.ToString());
    Console.WriteLine("transaction info=" + pubTrans.Information);
}
catch (Exception e)
{
    Console.WriteLine(e.Message, e.StackTrace);
}

Above, the transaction ID and Item Type print fine. I have other code where the Delete method works fine, but any time I try and get the Information, it blows up.

Here is the error:

<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ErrorCode="D"
           Category="18" Source="Kernel" Severity="1">
  <tcm:Line Cause="false" MessageID="16138">
    <![CDATA[Unable to get Information of Unknown (tcm:0-166535-66560).]]>
    <tcm:Token>RESID_4485</tcm:Token><tcm:Token>Information</tcm:Token>
    <tcm:Token>RESID_4663</tcm:Token><tcm:Token>tcm:0-166535-66560</tcm:Token>
  </tcm:Line>
  <tcm:Line ErrorCode="D" Cause="true"><![CDATA[Type mismatch]]></tcm:Line>
  <tcm:Details>
    <tcm:CallStack>
      <tcm:Location>PublishTransaction.Information</tcm:Location>
      <tcm:Location>PublishTransaction.Information</tcm:Location>
    </tcm:CallStack>
  </tcm:Details>
</tcm:Error>

I've searched the SDL Tridion World forum and couldn't find the answer. Am I missing a hotfix, should I contact Support, or is there another way to get the transaction info?

3

There are 3 answers

0
Hendrik Beenker On

I don't have a working environment, so I am just looking into whatever existing code I have available. This is snippet from the Event system which deletes a Queue item only when you have Admin privileges:

public void OnPublicationPublishPost(Publication publication, IXMLDOMDocument2 publishResult)
{
    TDSE tdse = Utilities.GetTDSEInstance();
    publishResult.setProperty("SelectionNamespaces", "xmlns:tcm=\"http://www.tridion.com/ContentManager/5.0\"");
    PublishTransaction publishTransaction = Utilities.GetTridionItem<PublishTransaction>(publishResult.selectSingleNode("/*/*").attributes[2].text, null) as PublishTransaction;
    User user = Utilities.GetTridionItem<User>(publishResult.selectSingleNode("/tcm:PublishResponse/tcm:PublisherRequest/tcm:User").attributes[0].text, null) as User;
    TDSPrivileges isAdmin = user.privileges;
    if (isAdmin != TDSPrivileges.TdsPrivilegeSystemAdministrator)
    {
        publishTransaction.Delete();
    }
}
3
Siva Charan On

I tried this in another way to get the PublishTransaction Information. Below is the code:-

PublishTransaction pubTrans = (PublishTransaction)tdse.GetObject(
                                                    "tcm:0-4294103-66560",
                                                    EnumOpenMode.OpenModeView, 
                                                    null, 
                                                    XMLReadFilter.XMLReadNull);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(pubTrans.GetXML(XMLReadFilter.XMLReadAll));
XmlNamespaceManager nameSpace = new XmlNamespaceManager(xmlDoc.NameTable);
nameSpace.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
nameSpace.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
Console.WriteLine("transaction id=" + pubTrans.ID); 
Console.WriteLine("transaction itemtype=" + pubTrans.itemType.ToString());
EnumPublishTransactionState transState = pubTrans.get_State();
if (transState == EnumPublishTransactionState.Failed)
  Console.WriteLine("transaction info=" + 
    xmlDoc.SelectSingleNode("/tcm:PublishTransaction/tcm:Data/tcm:Information",
    nameSpace).InnerText); 
1
Chris Summers On

I am not really sure (without digging further at this time of night), but is the 'Information' property actually an XMLElement rather than a string as the docs say? When you use a debugger, are you able to place a watch on this property to see what it contains?