Copied to clipboard

Flag this post as spam?

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


  • Tony Kiernan 278 posts 341 karma points
    Jul 26, 2012 @ 12:55
    Tony Kiernan
    0

    Altering date at import

    Is there a way to add time to a date being imported? 

    I have been using a 'Closing date' value as the 'Unpublish' date, effectively removing out of date content from a scheduled import.

    However, the node still needs to be available for that day, so the unpublish date should be Closing date + 1

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 06, 2012 @ 07:22
    Richard Soeteman
    0

    Hi Tony,

    It is possible to do this with some event handler code. The recordImporting event is the one you need to use since you can modify the values before the get assigned to the property.

    Below some code (haven't tested this on a site but should work).

      public class SetUnpublish : ApplicationBase
        {
            public SetUnpublish()
            {
                ContentImport.RecordImporting += new ContentImport.RecordImportingEventHandler(ContentImport_RecordImporting);
            }
    
            void ContentImport_RecordImporting(object sender, RecordImportingEventArgs e)
            {
                //Add an extra day, you might check if teh value is null or not
                ((DateTime)e.Items["ClosingDate"]).AddDays(1);
            }
        }

    Hope this helps you,

    Richard

     

  • Tony Kiernan 278 posts 341 karma points
    Aug 06, 2012 @ 12:45
    Tony Kiernan
    0

    Hmmm

    The type or namespace name 'RecordImportingEventArgs' could not be found (are you missing a using directive or an assembly reference?)
  • Tony Kiernan 278 posts 341 karma points
    Aug 06, 2012 @ 13:05
    Tony Kiernan
    0

    OK, added

    using CMSImport.Extensions.Import;
    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;

    Seems happier. Now to test the scheduling...

Please Sign in or register to post replies

Write your reply to:

Draft