Skip to main content
Solved

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


Forum|alt.badge.img
  • Freshman II
  • 28 replies

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.

 

 

Best answer by Naveen Boga

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

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

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • Answer
  • August 31, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • August 31, 2021

 


Forum|alt.badge.img
  • Author
  • Freshman II
  • 28 replies
  • September 1, 2021

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

     

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • September 1, 2021

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

 


Forum|alt.badge.img
  • Author
  • Freshman II
  • 28 replies
  • September 7, 2021

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


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