Hello -
I have a content type which include field named "created" which is a timestamp with default of "now".
When i execute queries on this content type i get "null" as the value of this field although it is populated.
Why is that?
Hello -
I have a content type which include field named "created" which is a timestamp with default of "now".
When i execute queries on this content type i get "null" as the value of this field although it is populated.
Why is that?
Hi Yossin,
Iâll be happy to help.
Can you tell me where you added this timestamp in the top content section or in a slice?
Hi Phil -
Thanks for the fast repsonse.
i put it in the top
OK, when are seeing the null value, is this after youâve published and in your project? or is when you are trying to preview?
itâs after i published already. You can see it in the content type âmarket_analysisâ
Hi Phil
Any update on this one?
I canât view the content type âmarket_analysisâ on your repo as itâs set to private.
Anyway I think I know what the issue is.
If this was a field that you added to an existing custom type, then you will need to go in to the document and make a change, maybe even select the time in the timestamp field itself, then re-publish the page to trigger this update.
This is because the when a document is published it takes a âsnapshotâ of the content at that time, so new changes made to the custom type after this point will not be automatically added. This is to protect projects from breaking changes being made in the custom types.
For any NEW documents that you create after this, the timestamp field will be automatically set, itâs only for pre-existing documents that you would get this issue.
OK.
But i have 1618 articles like that. I cannot go one by one.
What else do you suggest?
You could use the import/export feature to trigger all the timestamps. It might be as easy as exporting and immediately re-importing. Though you would have to test that to be sure.
Let me get that straight:
The problem is that i cannot import more than 100 items in one batch âŚ
Yes, thatâs the idea. I appreciate that itâs not ideal, though updating 100 documents at a time will be less time consuming that 1 at a time.
You can import up to 200 docs in a batch, are you documents quite large is this why you would like to limit the import to 100 per batch?
Thanks!
I have just made a little experiment:
i went into some document, and made a change and published it again of course
Afterwards i went into api browser and fetched it.
I did see the change i made however the âcreatedâ field is still null.
What do you suggest?
I would try editing the ''created" field itself to trigger the change.
That did the trick!
However, do you really think that exporting and re-importing will suffice?
I am asking you this again since the timestamp field didnât get changed unless i changed it explicitly.
Also i would like to explain why i need all this:
I imported to Prismic articles which were created in the past. Their creation timestamp of them is critical for me. Thatâs why i added this field in the first place.
Only after i was done with configuring the content type, i imported the data.
Is there any option in Prismic to some how create a document âin the pastâ? without the need for this field?
OK, thatâs a slightly different question.
So each of these documents will have a different date from the past? If thatâs the case there is no way for the import/export or Prismic to know what that date should be.
The import export would only trigger the date for today.
OK.
So we are left with this field that i have created.
Now youâre basically telling me that if i export everything and re-import then this timestamp will get fixed?
Yes, thatâs the idea. I havenât tested it, but if you import a test batch you can check to see if that field is updated with todays date.
OK
i exported the files and re-imported one of them. The âcreatedâ field remains as null
This is the definition of my custom type:
{ "Main" : { "title" : { "type" : "StructuredText", "config" : { "single" : "heading1", "label" : "Title" } }, "body" : { "type" : "StructuredText", "config" : { "multi" : "paragraph, preformatted, heading1, heading2, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item", "label" : "Body" } }, "author" : { "type" : "Link", "config" : { "select" : "document", "customtypes" : [ "author" ], "label" : "Author" } }, "created" : { "type" : "Timestamp", "config" : { "label" : "Created", "default" : "now" } }, "uid" : { "type" : "UID", "config" : { "label" : "uid" }
The whole issue seems like a bug inside Prismic or am i missing somthing here?
OK.
After banging my head for hours i finally understood what happened:
I imported the articles with timestamp field in the format of â2014-05-14T11:58:00.000Zâ
The Prismic imported doesnât complain about it and does the job. Moreover, you will see the correct timestamp in the article itself after importing it.
However, when you go to API browser or just uses the API to query the article, you will get null in this field instead.
The correct format should be: 2014-05-14T11:58:00+0000 (assuming itâs UTC)
@Phil - i suggest you tell it to your guys there so they do something about it
In the meantime i will change the timestamp format and import again