Event System Error with Tridion User Interface (Experience Manager)

We publish an additional page using the event system when publishing events on pages. It works well when we publish a page from CME. When we create a page using the Tridion UI, it is created and published as expected, but the event system generates an error when trying to create an object of the target type.

try { foreach (var t in e.Targets) { var targets = new List<TargetType>(); some logic targets.Add(new TargetType(t.Id, page.Session)); // error is in this line PublishInstructionBase pib = e.PublishTransactions.First().Instruction; PublishInstruction pi = new PublishInstruction(page.Session); pi.StartAt = pib.StartAt; pi.RollbackOnFailure = pib.RollbackOnFailure; PublishEngine.Publish( items, pi, targets, PublishPriority.Low ); } } 

The exception we get is an InvalidURIException

Both t and sessions are definitely not empty, which we checked by writing a log there.

Please tell me that we can fix the problem?

We will be able to fix this if you work a little bit on the code creation in try catch and create the target type manually if there is an exception, because we know that the publication of the Tridion UI is published only at the beginning.

Thanks Vikas Kumar

+4
source share
2 answers

It is difficult to say without exception the trace of the stack, but I assume that you need to read TargetType first and not try to create it, for example:

 (TargetType) page.Session.GetObject(t.Id) 
+3
source

The URIs you are using may not be from the same publishing context and therefore are not valid.

+1
source

All Articles