Solved

Restrict Copying of UDF value while creating new document from existing ones

  • 31 August 2021
  • 5 replies
  • 278 views

Userlevel 2
Badge

I have created a field in PO Header, it contains certain values, while creating a new document using “Copy” function, how can i restrict copying of that UDF value.

 

 

icon

Best answer by Naveen Boga 31 August 2021, 07:29

View original

5 replies

Userlevel 7
Badge +17

Hi @sd79  Please find the sample code to do not copy the fields on Copy Paste. 

 

Replace usrTestField1 with your Custom Field.

 public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
{
[PXViewName(PX.Objects.PO.Messages.POOrder)]
[PXCopyPasteHiddenFields(typeof(POOrderExt.usrTestField1), typeof(POOrderExt.usrTestField2))]
public PXSelectJoin<POOrder,
LeftJoinSingleTable<Vendor, On<Vendor.bAccountID, Equal<POOrder.vendorID>>>,
Where<POOrder.orderType, Equal<Optional<POOrder.orderType>>,
And<Where<Vendor.bAccountID, IsNull,
Or<Match<Vendor, Current<AccessInfo.userName>>>>>>> Document;

[PXCopyPasteHiddenFields(typeof(POOrderExt.usrTestField1), typeof(POOrderExt.usrTestField2))]
public PXSelect<POOrder, Where<POOrder.orderType, Equal<Current<POOrder.orderType>>,
And<POOrder.orderNbr, Equal<Current<POOrder.orderNbr>>>>> CurrentDocument;
}

Userlevel 7
Badge +17

 

Userlevel 2
Badge

Hi Naveen,

Thanks for your prompt response, I want to know one thing.

  1. [PXCopyPasteHiddenFields] is used for restricting copying of fields as well as UDF. -→ Got this point.
  2. Why we are redefining the same data views in the PO graph extension, though its already defined in the main POOrderEntry BLC

     

 

Userlevel 7
Badge +17

Hi @sd79  Yes your point is valid. On the copy action Acumatica will take the all the views and will paste all the views fields, hence we need to redefine the View and should be decorated with [PXCopyPasteHiddenFields].

 

There is another way probably you may looking of this. Please find the sample code for your reference. Hope this helps!!

if (this.IsCopyPasteContext)
{
sender.SetValue<SOOrder.usrCustomField1>(row, string.Empty);
}

 

Userlevel 2
Badge

Hi Naveen,

The below code brings me no luck for “do NOT copy of UDF value” while creating new document from old ones.

 

 protected virtual void POOrder_UsrForecastSupplierPayment_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            var row = (POOrder)e.Row;
            if (this.Base.IsCopyPasteContext)
            {
                e.NewValue = "";
                e.Cancel = true;
                return;
            }
        }

Its not working for System field as well 

 

  protected virtual void POOrder_OrderDesc_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            var row = (POOrder)e.Row;

            POOrder ord = e.Row as POOrder;
            if (ord == null) return;
            if (Base.IsCopyPasteContext)
            {
                e.NewValue = "";
                e.Cancel = true;
                return;
            }
          
        }

 

FYI i am working on 2020R2 Version.

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