Job Attachment showing duplicate Attachment


We have some method to attach the latest documents from external server in Part Level whenever part is loaded. Means we delete the old file and reattached the latest one. This is working fine no issue in that.

Now this same thing we need on Job level but at job level epicor behave differently. When job is load and part and revision is selected, its bydefault will load all documents from Part thus from xFileRef file and in xFileattch it will create new record with Relatedtofile as JobHead.

When job is load I am purposly deleting xfileAttch of this job and reinserting it with latest documents of Parts.
Now when checking in epicor Job entry, its bydefault its showing earlier old attachment and new one which I recently inserted…but in DB its showing only one time and not duplicate.

Any way how this can be done