Insert and Attach a Document in Mykosmos Portal

  • Edit
1. First, we have to Insert the document as a database record

Suppose we have the document "myfile.txt".

The JSON for insertion is:

{
       "INSERT_REC": { 
       "count": "1", 
       "AU_DOC": { 
       "AU_DOC": "your document id", 
       "FILE_NAME": "myfile.txt",
       "DESCR": "A simple text file",
       "AU_DOC_RELTYPE2": "1"
       }
   }
}

Upon database insertion, the system returns the Mykosmos ID (suppose "67890")

2. In the Server-Machine create a new folder named "DOC67890" under the "AutoDocuments" folder.

3. Upload the "myfile.txt" into the ...\AutoDocuments\DOC67890 folder

4. Update the previously inserted AU_DOC record, by adding two more fields, as follows:

{
       "UPDATE_REC": { 
       "count": "1", 
       "AU_DOC": { 
       "AU_DOC": "your document id", 
       "FILE_NAME": "myfile.txt",
       "DESCR": "A simple text file",
       "AU_DOC_RELTYPE2": "1",
       "STORED_FILE_NAME": "[AUTODOCUMENTSDIR]\AutoDocuments\DOC67890\myfile.txt",
       "DDIR": "[AUTODOCUMENTSDIR]\AutoDocuments\DOC67890"
       }
   }
}

In Mykosmos, the documents have to be attached to a specific database record. By supposing that the Database record belongs to the table "AU_BUSINESS" and has a unique record Id 234567, we have:

5.  Record insertion of the attachment of the document.

{
       "INSERT_REC": { 
       "count": "1", 
       "AU_DOC_REL": { 
       "AU_DOC_REL": "your id", 
       "RELDATE": "the date of the attachment",
       "REL_TABLE": "AU_BUSINESS",
       "REL_REC_ID": "234567",
       "AU_DOC": "67890"
       }
   }
}