Solved

Copy & Paste operation on custom form


Userlevel 7
Badge +8

I have a custom mater-detail screen and all standard action buttons including Copy & Paste. When I try to copy and paste an existing dataset to a new form, I get an error. I was wondering does Acumatica’s engine itself handles the copy and paste operations or I should write a custom code for it?

icon

Best answer by aaghaei 28 April 2022, 17:45

View original

13 replies

Userlevel 7
Badge +17

Hi, @aaghaei  Acumatica has inbuilt functionality that we can do COPY the existing data to a new record using the COPY button. NO NEED of writing extra code for Copy&Paste functionality.

 

Can you please let us know what error you are getting while doing this activity?

Userlevel 7
Badge +8

Hi @Naveen Boga 

This is my custom form

When I copy and enter the Doc PKs and try to paste I get this error

 

Userlevel 7
Badge +17

Hi @aaghaei  To identify the root cause, In your custom graph code, can you please comment all the events (Rowupdated/Fieldupdated/Fieldselecting) and do COPY&Paste and whether this issue is occurring or not.

Userlevel 7
Badge +8

Thank you @Naveen Boga for the prompt response. I commeted all event handers and still I get the same error. The only code I have in my graph now is:

 

    public class UDCTPMCashflowProjectionEntry : PXGraph<UDCTPMCashflowProjectionEntry, UDCTPMCashflowProjection>
{

[PXViewName("Project Cashflow Projections")]
public PXSelect<UDCTPMCashflowProjection> CashflowProjections;

public PXSelect<UDCTPMCashflowProjection,
Where<UDCTPMCashflowProjection.projectID, Equal<Current<UDCTPMCashflowProjection.projectID>>>> RevisionsFilter;

public PXSelect<UDCTPMCashflowProjectionSchedule,
Where<UDCTPMCashflowProjectionSchedule.projectID, Equal<Current<UDCTPMCashflowProjection.projectID>>,
And<UDCTPMCashflowProjectionSchedule.revisionID, Equal<Current<UDCTPMCashflowProjection.revisionID>>>>> CashflowProjectionSchedules;

public PXSelect<PMProject,
Where<PMProject.contractID, Equal<Current<UDCTPMCashflowProjection.projectID>>>> ProjectsFilter;
}

 

Userlevel 7
Badge +8

UPDATE @Naveen Boga,

I figured out what causes the issue. It is not the graph. it is a property of one of the DAC fields that I have commented in the below code.

        #region TranPeriodID
public abstract class tranPeriodID : PX.Data.BQL.BqlString.Field<tranPeriodID> { }
protected String _TranPeriodID;
[PeriodID(IsKey = true)]
//[CrossReferenceUniqueness(
// typeof(UDCTPMCashflowProjectionSchedule.tranPeriodID),
// ClearOnDuplicate = false,
// IgnoreDuplicatesOnCopyPaste = false,
// IgnoreNulls = true,
// UniqueKeyIsPartOfPrimaryKey = true,
// Where = typeof(Where2<Where<UDCTPMCashflowProjectionSchedule.projectID, Equal<Current<UDCTPMCashflowProjection.projectID>>>,
// And<UDCTPMCashflowProjectionSchedule.revisionID, Equal<Current<UDCTPMCashflowProjection.revisionID>>>>),
// ErrorMessage = "Month {0} already exist!")]
[PXParent(typeof(Select<UDCTPMCashflowProjection, Where<UDCTPMCashflowProjection.projectID, Equal<Current<UDCTPMCashflowProjectionSchedule.projectID>>,
And<UDCTPMCashflowProjection.revisionID, Equal<Current<UDCTPMCashflowProjectionSchedule.revisionID>>>>>))]
[PXUIField(DisplayName = "Month", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = false, Visible = true)]
public virtual String TranPeriodID { get; set; }
#endregion

Now I have to problems.

  1. How can check this field uniqueness in combination with ProjectID and RevisioID?
  1. Copy/Paste only pastes the header but doesnt do the detils. Any thought why?

 

Userlevel 7
Badge +8

Hi @Naveen Boga any thought why the Copy/Paste function pastes the master but not the details?

Userlevel 7
Badge

Hi @aaghaei were you able to resolve your issue? Thank you!

Userlevel 7
Badge +8

Hi @Chris Hackett Acumatica’s out of box copy/paste option didn’t work. to make it work, I added a custom button that when clicked displays a dialog to get PK fields, creates a new document and then loops through the base document lines and inserts into the new document and saves it.

Userlevel 7
Badge

Thank you for the updates @aaghaei !

Userlevel 3
Badge +1

Hi, @aaghaei  Acumatica has inbuilt functionality that we can do COPY the existing data to a new record using the COPY button. NO NEED of writing extra code for Copy&Paste functionality.

 

Can you please let us know what error you are getting while doing this activity?

@Naveen Boga have you ever created anything which copy/pastes the attachments (images) from one item to another? Base Acumatica appears to copy notes but not attachments. 

Userlevel 7
Badge +8

My apology to ​​​​​​@Naveen Boga if I am interfering. @asmith50 as you have figured out the out-of-box won't do it for you. You will need a custom action. Assuming you know how to do the rest and are only stuck with bringing over attachments from the previous record, the below code will do the work for you where:

  • Base: is your Base Graph
  • target: is the new instance of the Base Graph
  • MyView: is your Public View for the record(s)
  • row: is the current record you want to copy
  • rowCopy: is the copy of the current record
using PX.Data;

// Stuff here

// Below two lines will copy the Attachments
Guid[] files = PXNoteAttribute.GetFileNotes(Base.MyView.Cache, row);
PXNoteAttribute.SetFileNotes(target.MyView.Cache, rowCopy, files);


// Below two lines will copy the Notes
string note = PXNoteAttribute.GetNote(Base.MyView.Cache, row);
PXNoteAttribute.SetNote(target.MyView.Cache, rowCopy, note);

// Stuff here

 

Userlevel 7
Badge +17

Hi, @aaghaei  Not a problem! I apologize for missing this message, I have been occupied with other things in the past few days. Thank you very much for taking the time to respond with the information. 

Userlevel 7
Badge +8

@Naveen Boga I know what you mean. I sometimes also don’t even get a chance to have a look at the community posts but sometimes have more spare time :).

 

Thank you for all your support pal. 

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