Actions to be done at 3 stages
1) Create Fileupload item by right clicking on design as shown in image below
2)Change Properties especially Fileuploadstrategyclass to "FileUploadTempStorageStrategy" as shown in image below..png)
3) After that to store file in Docref use logic in OnUploadCompleted() method
[Form]
public static class DaxTestingForm extends SysLookupMultiSelectGrid
{
#characters
[Control("Custom")]
class ImageUpload
{
/// <summary>
///
/// </summary>
public void OnUploadCompleted()
{
FileUploadTemporaryStorageResult result = this.getFileUploadResult() as FileUploadTemporaryStorageResult;
super();
if(result && result.getUploadStatus())
{
str fileName = "YourFileName.pdf"; //Insert the name of the attachchment
using(System.IO.MemoryStream stream = result.openResult() as System.IO.MemoryStream)
{
DocuRef docuRef = DocumentManagement::attachFile(
MainAccountTable.TableId, // The Table Id that will be linked to the the attachment
MainAccountTable.RecId, //The RecId of the record that will be linked to the attachment
curext(),
DocuType::typeFile(),//Input here the attachment type
stream,
fileName,
null,
fileName);
}
}
}
}
}
Otuput:-