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;
}
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.

  • Thanks Rick, You are right. We tried that and it's working. – Sourav Garg Feb 3 '16 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, privacy policy and cookie policy

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