Friends, Normally we attach a document using the Document handling
icon on the tool bar and select appropriate options in attaching a file.
Well, I was going through smmDocuments form and found a drag drop ActiveX control which can make our life easier in quickly dragging and dropping the files [Yes, we need to write some code to add documents ,but its simple].
Please Note: I am assuming that you have setup document Management from Basic > Setup >> Document Management.
Lets see how we can do this to achieve the Drag-drop feature of files to attach documents directly to your document Management file system.
I am going to customize the custTable form as an example
Step 1: Go to AOT >> Forms >> CustTable
Step 2: Go to the designs node, Right click >. New Control >> ActiveX Control and select smmDrop2.smmDropWin activeX as shown below [Please note: If you are unable to see this class Id, it means you don’t have enough license keys ]

Once you drag drop the activeX control, Open the custTable form and you should see the control at the bottm left as shown below.

Step 3: Expand the activeX control and adda method onevent_DropFile event method
Step 4: Copy paste the below code to hit two tables DocuRef and docuValue to store the paths and the filename.
// AOSRunMode::Client
void onEvent_DropFile(COMVariant _strFilePath)
{
DocuRef tdocuRef;
DocuValue tdocuValue;
NumberSeq numSeq;
FileName _fileName;
FileName draggedFile = _strFilePath.bStr();
Num newFileNum;
DocuType docuType;
FileName fileName;
;
tdocuRef.RefRecId = custTable.RecId;
tdocuRef.RefTableId = custTable.TableId;
tdocuref.RefCompanyId = curext();
select docuType where docuType.ActionClassId == classnum(DocuActionArchive) &&
docuType.TypeId == ‘file';
// Get next number from number sequence
numSeq = NumberSeq::newGetNum(DocuParameters::numRefDocuNumber(), true);
ttsbegin;
newFileNum = numSeq.num();
[tDocuValue.FileName, tDocuValue.FileType, tDocuValue.Path] = Docu::splitFilename(draggedFile);
_fileName = DocuParameters::find().ArchivePath;
if (!Docu::validateExtension(tDocuValue.FileType))
{
// Files with this file type cannot be attached.
throw error(“@SYS99219″);
}
filename = _fileName + newFileNum + (tDocuValue.FileType ? (‘.’ + tDocuValue.fileType) : ”);
// If file already exists , use next next number
while(WinAPI::fileExists(filename))
{
numSeq.used();
numSeq = NumberSeq::newGetNum(DocuParameters::numRefDocuNumber(), true);
newFileNum = numSeq.num();
filename = _fileName + newFileNum + (tDocuValue.fileType ? (‘.’ + tDocuValue.FileType) : ”);
}
tDocuValue.fileName = newFileNum;
tDocuValue.insert();
tDocuRef.ValueRecId = tdocuValue.RecId;
tDocuRef.TypeId = docuType.TypeId;
tDocuRef.write();
// Create the file reference
tdocuValue.insert();
if (numSeq)
{
// Mark the document numbersequence number as used
numSeq.used();
}
winapi::copyFile(draggedFile, fileName);
ttscommit;
info(strfmt(‘Document %1 attached successfully’, draggedFile));
}
If there is any other easy way of implementing the same above code, you can do that.
Step 5: There you go. We are done with the coding part. Compile the form. Now try dragging and dropping the files on the icon shown in the custTable form. [Below is the the reference screen shot]

You can even drag drop the files even if your form is inactive and is minimized[exactly how we drag and drop feature of outlook] as shown below

If you want to use this feature on any other form repeat the same steps mentioned above but only change 2 lines of code
tdocuRef.RefRecId = custTable.RecId; // Change the active record – vendTable.recId
tdocuRef.RefTableId = custTable.TableId; // Change the active recid – vendTable.TableId
Well, I was going through smmDocuments form and found a drag drop ActiveX control which can make our life easier in quickly dragging and dropping the files [Yes, we need to write some code to add documents ,but its simple].
Please Note: I am assuming that you have setup document Management from Basic > Setup >> Document Management.
Lets see how we can do this to achieve the Drag-drop feature of files to attach documents directly to your document Management file system.
I am going to customize the custTable form as an example
Step 1: Go to AOT >> Forms >> CustTable
Step 2: Go to the designs node, Right click >. New Control >> ActiveX Control and select smmDrop2.smmDropWin activeX as shown below [Please note: If you are unable to see this class Id, it means you don’t have enough license keys ]

Once you drag drop the activeX control, Open the custTable form and you should see the control at the bottm left as shown below.

Step 3: Expand the activeX control and adda method onevent_DropFile event method
Step 4: Copy paste the below code to hit two tables DocuRef and docuValue to store the paths and the filename.
// AOSRunMode::Client
void onEvent_DropFile(COMVariant _strFilePath)
{
DocuRef tdocuRef;
DocuValue tdocuValue;
NumberSeq numSeq;
FileName _fileName;
FileName draggedFile = _strFilePath.bStr();
Num newFileNum;
DocuType docuType;
FileName fileName;
;
tdocuRef.RefRecId = custTable.RecId;
tdocuRef.RefTableId = custTable.TableId;
tdocuref.RefCompanyId = curext();
select docuType where docuType.ActionClassId == classnum(DocuActionArchive) &&
docuType.TypeId == ‘file';
// Get next number from number sequence
numSeq = NumberSeq::newGetNum(DocuParameters::numRefDocuNumber(), true);
ttsbegin;
newFileNum = numSeq.num();
[tDocuValue.FileName, tDocuValue.FileType, tDocuValue.Path] = Docu::splitFilename(draggedFile);
_fileName = DocuParameters::find().ArchivePath;
if (!Docu::validateExtension(tDocuValue.FileType))
{
// Files with this file type cannot be attached.
throw error(“@SYS99219″);
}
filename = _fileName + newFileNum + (tDocuValue.FileType ? (‘.’ + tDocuValue.fileType) : ”);
// If file already exists , use next next number
while(WinAPI::fileExists(filename))
{
numSeq.used();
numSeq = NumberSeq::newGetNum(DocuParameters::numRefDocuNumber(), true);
newFileNum = numSeq.num();
filename = _fileName + newFileNum + (tDocuValue.fileType ? (‘.’ + tDocuValue.FileType) : ”);
}
tDocuValue.fileName = newFileNum;
tDocuValue.insert();
tDocuRef.ValueRecId = tdocuValue.RecId;
tDocuRef.TypeId = docuType.TypeId;
tDocuRef.write();
// Create the file reference
tdocuValue.insert();
if (numSeq)
{
// Mark the document numbersequence number as used
numSeq.used();
}
winapi::copyFile(draggedFile, fileName);
ttscommit;
info(strfmt(‘Document %1 attached successfully’, draggedFile));
}
If there is any other easy way of implementing the same above code, you can do that.
Step 5: There you go. We are done with the coding part. Compile the form. Now try dragging and dropping the files on the icon shown in the custTable form. [Below is the the reference screen shot]

You can even drag drop the files even if your form is inactive and is minimized[exactly how we drag and drop feature of outlook] as shown below

If you want to use this feature on any other form repeat the same steps mentioned above but only change 2 lines of code
tdocuRef.RefRecId = custTable.RecId; // Change the active record – vendTable.recId
tdocuRef.RefTableId = custTable.TableId; // Change the active recid – vendTable.TableId
The information you have deliver here is really useful to make my knowledge good. Thanks for your heavenly post. It is truly supportive for us and I have accumulated some essential data from this blog.
ReplyDeleteDocument Management Software India
Document Management Software Chennai
Document Management Software
Electronic Document Management System