Hello Everyone,
We have requirement to add the Files in the FILES section using the ADD LINK button. Can you please help me how to add the Files using ADD LINK button from Code?
Hello Everyone,
We have requirement to add the Files in the FILES section using the ADD LINK button. Can you please help me how to add the Files using ADD LINK button from Code?
Best answer by taras
Hi, Add Link button creates link between File and some Entity. To create this link from code you need to insert into NoteDoc NoteID of an Entity and FileID of a File. You can use code of Add Link button:
protected IEnumerable addLink(PXAdapter a)
{
try
{
PXFilter<FileDialog> fileDialog = FileDialog;
if (fileDialog != null && (fileDialog.Current?.Entity).HasValue && Files.Current != null)
{
PXDatabase.Insert<NoteDoc>(new PXDataFieldAssign[2]
{
new PXDataFieldAssign("NoteID", PXDbType.UniqueIdentifier, FileDialog?.Current?.Entity),
new PXDataFieldAssign("FileID", PXDbType.UniqueIdentifier, Files.Current.FileID)
});
}
return a.Get();
}
catch (PXDatabaseException ex)
{
if (ex.ErrorCode != PXDbExceptions.PrimaryKeyConstraintViolation)
{
throw ex;
}
throw new Exception("Can't insert link more than once", ex);
}
}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.