Skip to main content
Solved

Get files dialog 'Comments'


darylbowman
Captain II
Forum|alt.badge.img+13

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.

Best answer by jinin

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;
                                
                            }

View original
Did this topic help you find an answer to your question?

3 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 680 replies
  • Answer
  • January 27, 2022

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;
                                
                            }


darylbowman
Captain II
Forum|alt.badge.img+13
  • Author
  • 1608 replies
  • January 27, 2022

@jinin - Where does ‘GetFileByID’ come from?


darylbowman
Captain II
Forum|alt.badge.img+13
  • Author
  • 1608 replies
  • January 27, 2022

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!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings