So, I want to to catch content porter Import Start in the Event System and read the Items selected for import.

I can catch the Import Start by using the below code in Event System (Courtesy: the blog here by Anton Minko)

// Subscription
EventSystem.Subscribe<IdentifiableObject, SaveApplicationDataEventArgs>(OnImport, EventPhases.Initiated);

// Event Handler Method
private void OnImport(IdentifiableObject subject, SaveApplicationDataEventArgs eventArgs, EventPhases phase)
        if (subject.Session.ContextData.ContainsKey(TcmApplicationId.ImportExportService) &&
            subject.Session.ContextData[TcmApplicationId.ImportExportService] is ImportInstruction)
            // This control reach here once the Content Import starts.

But I can't get any Information about the selected Items to be ported.

I've tried:

  1. Check all the Context Data available in the session (subject.Session.ContextData), the only data I am getting is subject.Session.ContextData[TcmApplicationId.ImportExportService] which is a ImportInstruction object. It has other information about the import but not about the items selected for Import (ImportInstruction.UserMappings returns null)

  2. Check all the Event Arguments Context Variables in eventArgs.ContextVariables collection. No variable found.

  3. Check eventArgs.ApplicationDataCollection collection, Getting two application data entries there with the ids "tm:ItemTranslationOptions" and "tm:TranslationConfiguration", looks like these are related to translation. Though I have not checked what type of values it has.

Question: Is it possible to read the items selected in the import during this Event Phase?

  • 2
    The way I understand Anton's post, there is no event that is triggered when an entire batch is imported. Rather, each item created will trigger a separate event. In the event handler you can detect if it is triggered by an import, by looking at the ContextData of the Session. Hence I doubt if you can ever get a full list of items to be imported.
    – Quirijn
    Dec 30, 2016 at 17:24
  • I ran a quick import test by porting 2 components, the control reaches to the function (inside the if condition) only once for "Publication" subject. It means it is not for every item the event is fired and looks like per publication (and that suits my requirements). I will run few more tests importing items form multiple publication and update the question with the results. Dec 31, 2016 at 8:55
  • Do you have access to the zip file itself (or its location) - just wondering if you could access the transport package itself and drill down to the information you need as it will be in the collection of XML files anyway? (obviously nicer if you can API the bugger - but if not - perhaps some helper classes would be great to create) Jan 3, 2017 at 8:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.