Attach files programmatically using x++

Hi People,

I'm trying to attach files via a web api call (through postman). The file comes in saves the to the docuvalue and docuref tables and expected. but the "Preview" isnt showing. Kindly help...

Here's my code

public void insert()
    {
        DocuRef docuRefTable;
        DocuValue docuValueTable;

        str firstFilePath, firstFileTempPath, firstFileBase64, firstFileName, firstFileExtension;
       
        int64 _refRecId;
        int _refTableId = 16462;
        BinData binData;
        System.IO.FileStream FileStream ;
        System.Byte[] byte;
        FileIoPermission perm;
        String20 returnMsg;
        str strUTF8Input;
        FileIOPermission permission = new FileIOPermission('', 'r');
        permission.assert();
        
        firstFileBase64 = this.FirstFileBase64;
        firstFileName = this.FirstFileName;
        firstFileExtension = this.FirstFileExtension;

        _refRecId = str2Int64(this.PointSourceAppRegRecId);
        firstFilePath = System.IO.Path::GetTempPath(); //Get temp path

        //str64 = System.Convert::ToBase64String(_byteArray);//Convert input Byte array in base64 string

        firstFileTempPath = firstFilePath + firstFileName + '.' + firstFileExtension;

        if (_refRecId > 0)
        {

            ttsBegin;
            docuValueTable.clear();
            binData = new binData();
            docuValueTable.File = BinData::loadFromBase64(firstFileBase64);
            docuValueTable.Name = firstFileName;
            docuValueTable.FileName = firstFileName;
            docuValueTable.FileType = firstFileExtension;
            docuValueTable.OriginalFileName = firstFileName + "." + firstFileExtension;
            docuValueTable.Path = firstFileTempPath;
            docuValueTable.insert(); // insert into DB

            if (docuValueTable.RecId)
            {
                docuRefTable.clear();
                docuRefTable.RefRecId = _refRecid;
                docuRefTable.RefTableId = _refTableId;
                docuRefTable.RefCompanyId = curext();
                docuRefTable.Name = firstFileName;
                docuRefTable.TypeId = 'File';
                docuRefTable.ValueRecId = docuValueTable.RecId;

                docuRefTable.insert();
                returnMsg = "Uploaded successfully";
            }
            ttsCommit;
        }
        else
        {

            returnMsg = "Record not exit for the given Id";
        }

        //return returnMsg;

        super();
    }

Parents
No Data
Reply Children
No Data
Related
Recommended