         addGlobalLogsObserver(self) // Add the document to globals logs observer
         BartlebyDocument.declareTypes()
 
+        self.metadata.document=self
+
         // Setup the spaceUID if necessary
         if (self.metadata.spaceUID==Default.NO_UID) {
             self.metadata.spaceUID=self.metadata.UID

    internal var _metadataFileName: String { return "metadata" + BartlebyDocument.DATA_EXTENSION }

    // The Document Metadata
    dynamic open var metadata=DocumentMetadata(){
        didSet{
            metadata.document=self
        }
    }
    // Triggered Data is used to store data before data integration
    internal var _triggeredDataBuffer:[Trigger]=[Trigger]()



        Bartleby.sharedInstance.declare(self)
        addGlobalLogsObserver(self) // Add the document to globals logs observer
        BartlebyDocument.declareTypes()

        self.metadata.document=self

        // Setup the spaceUID if necessary
        if (self.metadata.spaceUID==Default.NO_UID) {
