2

I am having trouble on fetching the PublishContext from the PublishTransactionData object using Core Service. It always return null for all type of transactions. In my below code Snippet the value of pContextData is null.

filterData.PublishTransactionState = PublishTransactionState.Success;
filterData.StartDate = DateTime.Parse("1/29/2016 3:11:29 PM");
filterData.EndDate = DateTime.Parse("2/2/2016 3:11:29 PM");
filterData.PublicationTarget = new LinkToPublicationTargetData()
{
     IdRef = publishstate
};

foreach (PublishTransactionData transaction in client.GetSystemWideList(filterData))
{
IEnumerable<PublishContextData> pContextData = transaction.PublishContexts;
}

2 Answers 2

4

The PublishContexts property is null because you are requesting a list of PublishTransactions and, in general, for lists only a subset of the properties are loaded.

If you read an individual PublishTransaction, the property will have a value.

1
  • Thanks Rick, You are right. We tried that and it's working. Feb 3, 2016 at 20:42
1

By recreating the PublishTransactionData object again with transaction id, I am able get the PublishContext. Not sure whether I was doing something wrong or core service issue, but below code is working for me.

filterData.PublishTransactionState = PublishTransactionState.Success;
filterData.StartDate = DateTime.Parse("1/29/2016 3:11:29 PM");
filterData.EndDate = DateTime.Parse("2/2/2016 3:11:29 PM");
filterData.PublicationTarget = new LinkToPublicationTargetData()
{
    IdRef = publishstate
};

foreach (PublishTransactionData transaction in client.GetSystemWideList(filterData))
{
    //IEnumerable<PublishContextData> pContextData = transaction.PublishContexts;
    PublishTransactionData pTransactionData = (PublishTransactionData)client.Read(transaction.Id.ToString(), null);
    PublishContextData pContextData = pTransactionData.PublishContexts[0];

}

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.