I'm trying to retrieve the Remove At date from within the Umbraco API. It returns DateTime.MinValue every time, even if a node does have a Remove At date associated with it.
I don't see any other properties for the Document object that I could use instead.
Everything else is pulling correctly except ExpireDate. I've saved, and re-published the doc that does have the Remove At date set. I shouldn't need to do anything else with it, correct?
Strange...what version of Umbraco are you using? I tested here on one of the 4.7 nightlies and it pulls the ExpireDate correctly. I do get DateTime.MinValue when I don't have it set, but after setting and saving and re-loading the page it comes in correctly.
No, regardless of whether it is set or not it returns 01/01/2001, which I checked and seems to match-up with DateTime.Minvalue.
Also, I didn't check the database *holding head in shame*. cmsDocument table? Getting the newest record for that node and expireDate is NULL. The interface is aware of the date even though it's not in the DB. Is there any reason it's not saving?
Or maybe just write out the doc.ExpireDate.ToShortDateTimeString(); to a label or something if you can - just to make sure not messing up any references ;-)
Bah, I meant to mark your second-last post as the answer. Either way, you got it. How the heck did you figure that one out?
When I iterate through doc.Children is it just loading certain fields on the child nodes with data (for db efficiency perhaps?), but a direct call to a node using an ID actually fully loads the data?.
I can't remember how I figured that out to be honest - I think it was just an experiment I made a while ago after pulling my hair for a good four hours ;-)
Also, I can't tell you why exactly it doesn't load the full data, maybe you're right about db effeciency.. I don't know!
However, I would like to know why it is like that - and also if it's a problem to do it that way. Maybe some MVP/Core person could shed some light on this for us? :-)
Can't Retrieve "Remove At" date from API
Hi All,
I'm trying to retrieve the Remove At date from within the Umbraco API. It returns DateTime.MinValue every time, even if a node does have a Remove At date associated with it.
I don't see any other properties for the Document object that I could use instead.
Any ideas?
Thanks,
Jay
Hi Jay,
How are you trying to access this?
yourDoc.ExpireDate should do the trick
Thanks,
Tom
Wow, might have helped if I put the code in my original post. ;)
That is the field I'm using, but it's coming back as DateTime.MinValue's value every time, which is 0001/01/01 I believe.
Everything else is pulling correctly except ExpireDate. I've saved, and re-published the doc that does have the Remove At date set. I shouldn't need to do anything else with it, correct?
Thanks,
Jay
Strange...what version of Umbraco are you using? I tested here on one of the 4.7 nightlies and it pulls the ExpireDate correctly. I do get DateTime.MinValue when I don't have it set, but after setting and saving and re-loading the page it comes in correctly.
I'm using v4.6.1. I just tried it on another node and same result: Jan 1, 0001.
I also deleted umbraco.config, recycled the app pools, etc., just to see if there was some sort of caching going on and no dice.
Weird! Tested here on 4.6.1 and seems to be working fine. Hmmm...
I'll keep poking around and see what I can come up with. At least I know I'm pulling the right field.
Thanks :)
Jay,
What exactly does the ExpireDate property return? null?
And.. have you checked to see if the value is actually stored in the database? Just to make sure, really :-)
No, regardless of whether it is set or not it returns 01/01/2001, which I checked and seems to match-up with DateTime.Minvalue.
Also, I didn't check the database *holding head in shame*. cmsDocument table? Getting the newest record for that node and expireDate is NULL. The interface is aware of the date even though it's not in the DB. Is there any reason it's not saving?
Hi Jay,
I know this is totally weird and doesn't seem to make any sense, but please try the following:
Just to see if it gives you the right output :-)
Or maybe just write out the doc.ExpireDate.ToShortDateTimeString(); to a label or something if you can - just to make sure not messing up any references ;-)
Bah, I meant to mark your second-last post as the answer. Either way, you got it. How the heck did you figure that one out?
When I iterate through doc.Children is it just loading certain fields on the child nodes with data (for db efficiency perhaps?), but a direct call to a node using an ID actually fully loads the data?.
Hi Jay,
I can't remember how I figured that out to be honest - I think it was just an experiment I made a while ago after pulling my hair for a good four hours ;-)
Also, I can't tell you why exactly it doesn't load the full data, maybe you're right about db effeciency.. I don't know!
However, I would like to know why it is like that - and also if it's a problem to do it that way. Maybe some MVP/Core person could shed some light on this for us? :-)
All the best,
Bo
is working on a reply...