Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Feb 20, 2012 @ 20:45
    Bo Damgaard Mortensen
    0

    Calling an import definition manually from code

    Hi all,

    Does anyone know if it's possible to call/trigger an import definition from a page/usercontrol using C#? :-)

    Thanks a lot in advance.

    All the best,

    Bo

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Feb 20, 2012 @ 21:22
    Richard Soeteman
    0

    Hi Bo,

    Yes this is possible. State objects are stored in the CMSImportState table of the Umbraco database. Get the guid stored in the UniqueIdentifier column for the state object you want to import. then use the following code to import the records.You need to add a reference to cmsimport.library.dll and cmsimport.extensions.dll

     

     

    var importState = StateHelper.GetPersistedStateByWizardID(new Guid("41ED1164-BE12-40F0-9FA8-23F9C8180B15"));
    ImportStatistics stats = ImportHelper.ExecuteImport(importState);

     

     

    ImportStatistics gives you some information about imported records.

    Hope this helps,

    Richard

  • Laura 3 posts 71 karma points
    Nov 28, 2016 @ 08:27
    Laura
    0

    Hi Richard,

    I am interested in calling an import manually from code as well, unfortunately the ExecuteImport(Guid importId) method is not longer in ImportHelper class.

    Is there another way to manually call an import function with the Id please?

    Cheers,

    Laura

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Feb 22, 2012 @ 08:30
    Bo Damgaard Mortensen
    0

    Works like a charm! :) Thanks a lot Richard - greatly appreciated!

Please Sign in or register to post replies

Write your reply to:

Draft