Skip to content

Instantly share code, notes, and snippets.

@yuriycto
Created April 21, 2023 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriycto/0772a453a6e70278bca6a9b1f3b017d9 to your computer and use it in GitHub Desktop.
Save yuriycto/0772a453a6e70278bca6a9b1f3b017d9 to your computer and use it in GitHub Desktop.
Delete attachment
var fileGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
var savedFilesIDs = PXNoteAttribute.GetFileNotes(this.Document.Cache, this.Document.Current);
foreach (var savedFileID in savedFilesIDs)
{
var savedFileInfo = fileUploadGraph.GetFile(fileID);
if (savedFileInfo != null
&& VerifyFileName(savedFileInfo.Name))
{
fileGraph.Files.AllowDelete = true;
fileGraph.Files.Delete(fileUploadGraph.Files.Current);
fileGraph.Persist();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment