Solved

How to Access the record is being copied from when Copy/Paste engine is running?

  • 4 October 2023
  • 9 replies
  • 102 views

Userlevel 7
Badge +8

Hello All,

When Acumatica’s Copy/Paste engine is running and the Graph’s IsCopyPasteContext is true how we can access the current record which is used as original record to create copy from it? In the event handlers as platform starts defaulting, inserting, … we can access the copy of the record but I don’t know how I can get the original record that drives the copied one.

icon

Best answer by Dmitrii Naumov 6 October 2023, 22:58

View original

9 replies

Userlevel 7
Badge +5

@aaghaei  I don’t think you can access the original record while it’s being inserted. 

The original record itself is not stored in memory during pasting. Instead, when you copy, the values are saved in memory(the same way as it is saved when you use ‘Save as Template’).

Userlevel 7
Badge +8

@Dmitrii Naumov Thank you for the reply. The case is the assigned value to the fields can change at any stage from the very beginning when its defaulting until it is persisted. Also there could be many extensions that manipulating the original properties, behavior's and values of the fields. So when we want to keep the value of some specific fields when they are copied, it drives us mad to dig into every single bit of code and see at what point point a value is assigned to the field which is not what user needs and override it and in some cases I have hit a concrete wall so I couldn’t go around. Access to the original record seems to me the most reliable option to override the values which are changed somehow and at some point during the copy/paste. Do you have any suggestion?

Userlevel 7
Badge +8

@Yuriy Zaletskyy can you please provide your thoughts here too?

Userlevel 7
Badge +5

@aaghaei In that case I don’t think you need the access to the record itself, right? You can just use the values that are stored in the clipboard, can’t you?

You can access it like that:

PX.Data.PXCopyPasteData<YourGraphType>.CurrentUserClipboard

Userlevel 7
Badge +8

@Dmitrii Naumov thanks for the hint. The case is the clipboard can have multiple records from multiple DACs depending on the Graph structure. How can I access to the exact record that currently is inserting into the cache resulting event be retriggered?

Userlevel 7
Badge +5

@aaghaei the records are not stored in the clipboard as records. It’s stored there as an import scenario (copy paste functionality actually uses import/export scenario engine to perform data read and data write). So I guess there is no way to access the record itself. In fact, it’s not being even inserted in one go. Depending on the import scenario structure, the data may be inserted in chunks.

Userlevel 7
Badge +8

@Dmitrii Naumov thanks for explaining the copy/paste working methodology. So with all these efforts getting nowhere, can we somehow force the platform to prioritize the the original values over the event handlers in CopyPasteContext?

Userlevel 7
Badge +5

@aaghaei I’m afraid the only way to do this is to check IsCopyPasteContext on each event overriding values. 

Userlevel 7
Badge +8

@Dmitrii Naumov  Thank you. Back to square 1. This is what I am doing currently and I was hoping to avoid. Thanks.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved