Solved

Get files dialog 'Comments'

  • 27 January 2022
  • 3 replies
  • 53 views

Badge +11

How can I programmatically get the ‘Comments’ of a file attached to an entity.

 

I’ve tried several different ways but the ‘Comments’ field always returns empty.

 

I can get the files with the following code:

UploadFileMaintenance uploadFileMaintenance = PXGraph.CreateInstance<UploadFileMaintenance>();
var files = PXNoteAttribute.GetFileNotes(Base.Message.Cache, email);

I tried this to get the comment:

string comment = uploadFileMaintenance.GetFileComment(file.Name) ?? string.Empty;

Also this:

string comment = file.Comment ?? string.Empty;

 

Nothing seems to work.

icon

Best answer by jinin 27 January 2022, 19:55

View original

3 replies

Badge +11

I just wrote a BQL select on those two tables in a fashion similar to what I assume that custom method did, and I got it to work. Thank you!

Badge +11

@jinin - Where does ‘GetFileByID’ come from?

Userlevel 7
Badge +11

Hi @Deetz 

Can you please try like below? 

Guid fileId = doc.FileID.Value;
 var result = (PXResult<UploadFile, UploadFileRevisionNoData>)GetFileByID(sender.Graph).SelectSingle(fileId);
                            UploadFile file = (UploadFile)result;
                            UploadFileRevision fileRev = (UploadFileRevision)result;
                            if (file != null && fileRev != null && !string.IsNullOrEmpty(file.Name))
                            {
                                
                                string comment = fileRev.Comment != null ? TextUtils.EscapeString(fileRev.Comment, '@', '$') : string.Empty;
                                
                            }

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved