Skip to main content
Solved

Copy & Paste operation on custom form


aaghaei
Captain II
Forum|alt.badge.img+10

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?

Best answer by aaghaei

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.

View original
Did this topic help you find an answer to your question?

13 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3412 replies
  • March 24, 2022

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?


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • March 24, 2022

Hi @Naveen Boga 

This is my custom form

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

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3412 replies
  • March 24, 2022

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.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • March 24, 2022

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;
    }

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • March 24, 2022

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?

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • March 25, 2022

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


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2769 replies
  • April 26, 2022

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


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • Answer
  • April 28, 2022

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.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2769 replies
  • April 28, 2022

Thank you for the updates @aaghaei !


asmith50
Jr Varsity III
Forum|alt.badge.img+1
  • Jr Varsity III
  • 70 replies
  • April 19, 2023
Naveen Boga wrote:

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. 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • April 20, 2023

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

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3412 replies
  • April 21, 2023

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. 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 1204 replies
  • April 21, 2023

@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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings