Hello,
I’m trying to get file info from the UploadFileMaintenance graph using the code below.
Unfortunately, the GetFile and GetFileWithNoData methods always returns null for me and I cannot understand why, and I’m out of ideas of try.
I’ve added comments to the code to explain what I believe is happening. Can anyone explain what I’m doing wrong please?
//create the CABatchEntry graph, find the batch I'm interested in and set the graphs 'current' record to the record I've found.
CABatchEntry graph = PXGraph.CreateInstance<CABatchEntry>();
PXResultset<CABatch> pXResults = SelectFrom<CABatch>.Where<CABatch.batchNbr.IsEqual<@P.AsString>>.View.Select(new PXGraph(), batchID);
graph.Document.Current = (CABatch)pXResults.TopFirst;
//create the UploadFileMaintenance graph
var fileUploadGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
//get a list of all FileIDs for the current record
var savedFilesIDs = PXNoteAttribute.GetFileNotes(graph.Document.Cache, graph.Document.Current);
//things appear to be working well at this point I have a 35 guids to loop through
foreach (Guid fileID in savedFilesIDs)
{
//the following 2 lines always returns null
var savedFileInfo = fileUploadGraph.GetFileWithNoData(fileID);
var savedFileInfo1 = fileUploadGraph.GetFile(fileID);
if (savedFileInfo != null)
{
fileUploadGraph.Files.AllowDelete = true;
fileUploadGraph.Files.Delete(fileUploadGraph.Files.Current);
fileUploadGraph.Persist();
}
}
Thanks
Best answer by davidnavasardyan09
View original