0

I would like copy the Promised Date from the Purchase Order (PO802388) Line to the Purchase Receipt Line (PO302000) when creating the PO Receipt.

I am trying the customisation project but could not find how to link the PO Receipt line to the Order Line to get the required date field. On the PO there will be multiple line for the same Inventory Item.

Any help will be appreciated. Many Thanks

A. Acuman
  • 1
  • 2

1 Answers1

0

Ignoring CompanyID which is automatically managed by the framework, there are three required key fields to select a POLine record: enter image description here

Fortunately those key values are available from POReceiptLine so you can link them like this:

POReceiptLine receiptLine = […];

PXResultset<POLine> poLine = PXSelectReadonly<POLine,
                             Where<POLine.orderType, Equal<Required<POLine.orderType>>,
                             And<POLine.orderNbr, Equal<Required<POLine.orderNbr>>,
                             And<POLine.lineNbr, Equal<Required<POLine.lineNbr>>>>>>.Select(Base,
                                                                                            receiptLine.POType,
                                                                                            receiptLine.PONbr,
                                                                                            receiptLine.POLineNbr);
Hugues Beauséjour
  • 8,067
  • 1
  • 9
  • 22
  • Thanks for looking into it. I tried the following coded as below but I am getting error. …. … …. using System; namespace PX.Objects.PO { public class POReceiptLineExt : PXCacheExtension { #region UsrPrmsedDate [PXDate] [PXUIField(DisplayName="AD Promised Date")] public virtual DateTime? UsrPrmsedDate { get; set; } public abstract class usrPrmsedDate : IBqlField { } POReceiptLine receiptLine = UsrPrmsedDate; – A. Acuman Dec 17 '18 at 15:44
  • PXResultset poLine = PXSelectReadonly>, And>, And>>>>>.Select(Base, receiptLine.POType, receiptLine.PONbr, – A. Acuman Dec 17 '18 at 15:44
  • receiptLine.POLineNbr); #endregion } } – A. Acuman Dec 17 '18 at 15:44
  • here is the error \App_RuntimeCode\POReceiptLineExtensions.cs(28): error CS0236: A field initializer cannot reference the non-static field, method, or property 'PX.Objects.PO.POReceiptLineExt.UsrPrmsedDate.get' \App_RuntimeCode\POReceiptLineExtensions.cs(33): error CS0120: An object reference is required for the non-static field, method, or property 'PX.Data.PXCacheExtension.Base.get' – A. Acuman Dec 17 '18 at 15:46
  • \App_RuntimeCode\POReceiptLineExtensions.cs(34): error CS0236: A field initializer cannot reference the non-static field, method, or property 'PX.Objects.PO.POReceiptLineExt.receiptLine' \App_RuntimeCode\POReceiptLineExtensions.cs(35): error CS0236: A field initializer cannot reference the non-static field, method, or property 'PX.Objects.PO.POReceiptLineExt.receiptLine' \App_RuntimeCode\POReceiptLineExtensions.cs(36): error CS0236: A field initializer cannot reference the non-static field, method, or property 'PX.Objects.PO.POReceiptLineExt.receiptLine' – A. Acuman Dec 17 '18 at 15:47
  • \App_RuntimeCode\POReceiptLineExtensions.cs(33): error CS0120: An object reference is required for the non-static field, method, or property 'PX.Data.PXSelectBase.Select(params object[])' \App_RuntimeCode\POReceiptLineExtensions.cs(28): error CS0236: A field initializer cannot reference the non-static field, method, or property 'PX.Objects.PO.POReceiptLineExt.UsrPrmsedDate.get' – A. Acuman Dec 17 '18 at 15:47
  • Steps i followed are 1. Created new Customization Project 2. On the Screen>Add Screen, I selected the PO receipt Screen 3. On the “CurrentDocument” Tab, I added a new Field UsrPrmsedDate ( with the Type NonPersistantField) 4. Published the Customisation and added the field to CurrentDocument section of the receipt 5. On the “Data Access” , “POReceiptLine is added. I clicked on “Convert to Extension” – A. Acuman Dec 17 '18 at 15:48
  • Change Base with this or graph? You must provide a graph object to the Select method first parameter. Which object refer to the proper graph I can't tell because you haven't added any context to your question. – Hugues Beauséjour Dec 17 '18 at 16:24
  • It seems context is in POReceiptLineExtensions.cs, please provide whole file in question. From the comments it appears you just copy pasted the floating query in a DAC extension instead of having it in a graph event handler. – Hugues Beauséjour Dec 17 '18 at 16:29
  • Sorry, i am new to the development, would you please send me the step by step instructions on how to do this if possible. – A. Acuman Dec 19 '18 at 11:31