Hello, the following code works in version 22.215.0056 but it doesn’t work in version 23.105.0016
UploadFileMaintenance upload = PXGraph.CreateInstance<UploadFileMaintenance>(); NoteDoc doc = upload.Select<NoteDoc>().First(x => x.NoteID == fromNoteID); if (doc == null) return; //no file attached - exit Guid g = ToGuid(doc.FileID); //this just converts guid? to guid PX.SM.FileInfo sourceFile = upload.GetFile(g);
In the older version upload.the GetFile method works and returns the details of the file to the sourceFile variable. In the new version the GetFile method always returns null.
I’ve checked the guid and the file I would like to access does exist in the UploadFile table. Is there a new way to access files in the newer versions for Acumatica?
Thanks Steve
Page 1 / 1
Hi @stephenward03,
Instead of doing a Select to get the FileID you can use PXNoteAttribute.GetFileNotes to get the list of Guid of the files attached to the document.
Also, from my testing I see GetFile get the file info as expected. Below is the screens of the debug information,
Following is the graph extension used for testing,
public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry> { #region Event Handlers public PXAction<SOOrder> getFileTest; PXUIField(DisplayName = "GetFileTest")] PXButton] protected IEnumerable GetFileTest(PXAdapter adapter) { UploadFileMaintenance upload = PXGraph.CreateInstance<UploadFileMaintenance>(); Guid ] g = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current); foreach (Guid item in g) { PX.SM.FileInfo sourceFile = upload.GetFile(item); } return adapter.Get(); } #endregion }
You can debug to see what is happening when you hit GetFile. Please feel free to post back to you have any question.! Happy Coding.!
Thanks for your comments @Vignesh Ponnusamy
I used the graph extension you provided and it worked on my system.
In my case, I want to use select and not PXNoteAttribute.GetFileNotes so I adjusted the code and tried again. upload.GetFile() returns the file details as expected from a button on sales orders. Which is great. See below.
However, if I try the same code from an override of ReleaseDocProc, then GetFile() still returns null. See below, ‘sourceFile‘ in the watch window is null.
So the problem might be linked to where I’m using the GetFile() method and not the syntax.
I’ve added my code below, would you be able to try this on your system please and let me know if you get the same results (you’ll need to update the RefNbr value), and how to work around this problem.
public class ARReleaseProcess_Extension : PXGraphExtension<PX.Objects.AR.ARReleaseProcess> { public static bool IsActive() => true;
Above is the SOOrderEntry extension - sourceFile works fine with this code.
Thanks
Steve
Hi @Vignesh Ponnusamy
I’ve been digging deeper into the source code using dnSpy. After checking a few things I updated the SQL record for my file to change the field ‘IsPublic’ from 0 to 1.
After making this change the code works! When I call GetFile() in ARReleaseProcess the file information is returned to my sourceFile variable.
I’m not sure why changing this field has worked, or what the IsPublic field is supposed to control. I’m creating the files in the first place so hopefully I will be able to set the file to be Public and then I’ll have access to it. Not sure.
Do you know more about this field?
Hi @stephenward03,
Thanks for sharing the interesting information.
In the File Maintenance(SM202510) screen, I see Is Public check box. And looks like the purpose of the check box is to allow all the user to access the file. Ignoring the access rights information,