Hello,
I have added a custom field named Type on the pop up dialog of attachments as shown below.
The value that is selected in Type field, I want to concatenate it with the file name of browsed attachment before traversing to SharePoint. Like Type is Certificates and browsed file name is ABC, resulted file name stored in DocuValue table should be ABC_Certifcates and propagate that file name all the way to SharePoint. Does anyone know how to do that in X++ code.
What about modified field of unbound control. On the modified method write code to insert unbound control value to table.
Thanks,
Girish S.
Written COC for uploadCompleted but the upload process is executed earlier and it is post notification. Tried COC for run also, but didn't worked. I'm looking for the OnUploadAttemptStarted override mentioned on Microsoft Doc. If have idea about it or some other approach to store unbound control value in table before DocumentManagement_Extension::attachFileToDocuRef(), let me know. Thanks
Try writing COC for uploadCompleted on the form method - On this method you can fill in the values to table from string control.
Thanks,
Girish S.
I have written COC for DocumentManagement, it is the base for data traversing and working fine.
[ExtensionOf(classStr(DocumentManagement))] final class DocumentManagement_Extension { public static DocuRef attachFileToDocuRef(RecId _docuRefRecId, System.IO.Stream _file, str _fileName, str _fileContentType, str _attachmentName, str _notes) { DocuRef docuRef; _fileName = CustomTable.field _fileName; _attachmentName = CustomTable.field _attachmentName; docuRef = next attachFileToDocuRef(_docuRefRecId,_file,_fileName,_fileContentType,_attachmentName,_notes); return docuRef; } }
but closeOk is not working, even debugger did not came.I nee to fill value in table before DocumentManagement class calling.
[ExtensionOf(formStr(DocumentUpload))] final class DocumentUpload_Extension { public void closeOk() { next closeOk(); Formrun thisForm = this; Common targetRecord = thisForm.args().record(); if (targetRecord && targetRecord.TableId == tableNum(DocuRef)) { DocuRef docuRef = targetRecord; Info(strFmt("Close ok %1 %2",docuRef.RecId,docuRef.ValueRecId)); } } }
I think you need to write COC for createFileAttachment and change the fileName there.
For the unbound control you need to create one table and insert the value on closeOk method of DocumentUpload form. You can write COC for closeOk if it's not implemented in standard.
Try like below.
public void closeOk() { next closeOk(); //create one table and insert the type value here. Delete the record in the table and reinsert them every time. } create extension class for DocuActionFile and add below code. public DocuValue createAttachmentFile(DocuRef _ref,str _fileName,str _fileContentType,System.IO.Streams _fileContents) { // add select statement to get type from newly created table and pass the fiel name to it. TableName tableName; select firstonly * from tableName; next createAttachmentFile(_ref,tableName.fileName _fileName, _fileContentType,_filecontents); }
I am not sure this will work but you can try as a workaround.
Thanks,
Girish S.
Hi Girish S,
I cannot COC for closeOk as it is not implemented on DocumentUpload form. moreover I write OnInserting event handler of the DocuValue table and set hard coded file name but that name did not traversed to SharePoint, I debugged and checked file name was propagated to SharePoint before DocuValue insert. See the call stack.
DocuValue:: Insert() DocuActionFile::createFileAttachement() >>> SharePoint upload at line 275 DocuActionFile::attachFile() DocuActionFile::attachFile() (here concatenated FileName needs to be send ) DocuHistory::UpdateRecordNames (updating from DocuRef > here also concatenated FileName to be used) DocuRef::Update DocuMentManagement::attachFileToDocuRef
On the DocumentUpload form - Write COC for closeOk method and see whether you are getting caller record as DocuRef and see value of ValueRecId field.
public void closeOk() { next closeOk(); //check whether you are able to get DocuRef using element.args().record(); }
Thanks,
Girish S.
Hi Girish S,
Problem is getting the value of custom field, as it is string control and its scope is within the dialog, not originating from data source. As document upload dialog box does not have a data source. So how to achieve it?
Hi Faran,
You can concatenate the File name in the OnInserting event handler of the DocuValue table.
Thanks,
Girish S.
André Arnaud de Cal...
292,162
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156