Course documents and their Ids

When you get a brand new CourseDocument in B2 like this

Content courseDoc = new CourseDocument();

there is a problem with the Id when using courseDoc.getId();

The Id you get is *NOT* the final – and therefore – correct Id of the CourseDoc! It is something seemingly random, not NULL as I’d expect from unset properties.

I tried many different ways to rectify this. For instance by setting the Id to something unique or using the URL (not set either). All of this work was in vain, and the final solution is a bit awkward, as I save the document using the persister and then reload it, which result in a document with the correct Id.

RESULT: I can now persist extra information in files using the Id as an identifier.

This entry was posted in Plugin development, Tagging and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *