0
votes

On the Bills and Adjustments page (others too), the Files indicator in the top right hand corner between Activities and Notifications displays the number of files attached. How do i get that number.

I've been playing with the following code, but it seems way overkill...i feel like there is probably a simple way to get it.

protected void getFiles()
{
    var projectCache = Base.Caches[typeof(PMProject)];
    Guid[] files = PXNoteAttribute.GetFileNotes(projectCache, projectCache.Current);
    foreach (Guid fileID in files)
    {
        var fm = new PX.SM.UploadFileMaintenance();
        PX.SM.FileInfo fi = fm.GetFileWithNoData(fileID);
    }
}
1

1 Answers

0
votes

You can check the Lenght property of the returned array:

var count = PXNoteAttribute.GetFileNotes(projectCache, projectCache.Current).Length;

I want to note that you must never use the constructor with graphs. The correct way is the following:

var fm = PXGraph.CreateInstance<UploadFileMaintenance>();