You can do a DB lookup on the existing attachment(s) during that BPM you are using and then create a new attachment with the same information as the original just a new RelatedToFile and Key set.
BufferCopy with excludes would work great for this.
This is what I have used in the past for creation of attachments. It’s more than what you need if you were to use BufferCopy to copy the order record and just alter the key fields. You would need to create a new attch record and then copy into that so it has the IDs and stuff you need.
Or you can use a version of below for your own purposes and that would work too.
Func<string, Guid, string, string, int> AttachFile = (iFilename, iRelatedGuid, iRelatedTable, iKey1) =>
{
int outAttchNum = 0;
using (var txscope = IceDataContext.CreateDefaultTransactionScope())
{
// Create the system file reference
XFileRef xref = new XFileRef();
Db.XFileRef.Insert(xref);
xref.Company = callContextClient.CurrentCompany;
xref.XFileName = $@"\\server\path\{iFilename}";
xref.XFileDesc = iFilename;
xref.DocTypeID = "CUSTOGPO";
Db.Validate(xref);
// Attach the file to the record
XFileAttch xfile = new XFileAttch();
Db.XFileAttch.Insert(xfile);
xfile.Company = callContextClient.CurrentCompany;
xfile.RelatedToSchemaName = "Erp";
xfile.RelatedToFile = iRelatedTable;
xfile.Key1 = iKey1.ToString();
xfile.ForeignSysRowID = iRelatedGuid;
xfile.XFileRefNum = xref.XFileRefNum;
Db.Validate(xfile);
// Store the new attachment number for a rainy day
outAttchNum = xfile.AttachNum;
txscope.Complete();
}
return outAttchNum;
};
int attchnum = AttachFile(ud11.Key2, std.OrderHed[0].SysRowID, "OrderHed", std.OrderHed[0].OrderNum.ToString());