Solved

Add counter for the number of times pick list printed

  • 27 June 2022
  • 4 replies
  • 116 views

Userlevel 2
Badge

I have added a custom field in SOPickingWorksheetShipment DACExtension which stores how many times action to print pick list in screen (SO302500) Picking Worksheets. 
Not able to save my values to the DB.

 

DACExtension

#region UsrPickListPrintCount
[PXDBInt]
[PXUIField(DisplayName="Pick List Print Count")]

public virtual int? UsrPickListPrintCount { get; set; }
public abstract class usrPickListPrintCount : PX.Data.BQL.BqlInt.Field<usrPickListPrintCount> { }
#endregion

GraphExtension

public class SOPickingWorksheetReview_Extension : PXGraphExtension<PX.Objects.SO.SOPickingWorksheetReview>
{
#region Actions
[PXButton(IsLockedOnToolbar = true), PXUIField(DisplayName = "Print Pick Lists")]
public virtual IEnumerable printPickList(PXAdapter a)
{
SOPickingWorksheetReview graph = PXGraph.CreateInstance<SOPickingWorksheetReview>();
SOPickingWorksheet row = Base.worksheet.Current;
SOPickingWorksheetShipment worksheetShipment = Base.shipmentLinks.Current;
SOPickingWorksheetShipmentExt worksheetShipmentExt = worksheetShipment.GetExtension<SOPickingWorksheetShipmentExt>();

if (worksheetShipmentExt.UsrPickListPrintCount >= 2)
{
if (Base.worksheet.Ask("Do you want to reprint this pick list?", MessageButtons.OKCancel)
!= WebDialogResult.OK) return a.Get();
}

//update print count
worksheetShipmentExt.UsrPickListPrintCount = worksheetShipmentExt.UsrPickListPrintCount ?? 0;
worksheetShipmentExt.UsrPickListPrintCount = worksheetShipmentExt.UsrPickListPrintCount + 1;
graph.shipmentLinks.Cache.SetValueExt<SOPickingWorksheetShipmentExt.usrPickListPrintCount>(worksheetShipment, worksheetShipmentExt.UsrPickListPrintCount);
graph.shipmentLinks.Update(worksheetShipment);
Base.Save.Press();

return Base.printPickList(a);
}
public PXAction<SOPickingWorksheet> PrintPickList;
#endregion
}

 

icon

Best answer by Naveen Boga 28 June 2022, 07:58

View original

4 replies

Userlevel 7
Badge +17

Hi @param2022  Are you using the proper view for the cache update?

It should be Worksheet view right, that you need to use?

 

 

Userlevel 2
Badge

@Naveen Boga If you are referring like this I already tried it and its also not working

graph.worksheet.Cache.SetValueExt<SOPickingWorksheetExt.usrPickListPrintCount>(row, rowExt.UsrPickListPrintCount);
graph.worksheet.Update(row);

I was trying to add it in shipmentLinks because that DAC has worksheetNo and shipmentNo both in it so it would be easy for me get data from that table. 

However for worksheet view also this was not working.

Userlevel 2
Badge

@Naveen Boga do you see any mistake i might be doing ?

Userlevel 7
Badge +17

Hi, @param2022  I made some changes to your code and can you please verify and confirm?

Below code should work for sure, if it is not working just comment the code if(count >= 2) and verify.

 


public class SOPickingWorksheetReview_Extension : PXGraphExtension<PX.Objects.SO.SOPickingWorksheetReview>
{
#region Actions
public PXAction<SOPickingWorksheet> PrintPickList;
[PXButton(IsLockedOnToolbar = true), PXUIField(DisplayName = "Print Pick Lists")]
public virtual IEnumerable printPickList(PXAdapter a)
{

SOPickingWorksheet row = Base.worksheet.Current;
if(row != null)
{
SOPickingWorksheetShipment worksheetShipment = Base.shipmentLinks.Current;
if(worksheetShipment != null)
{
SOPickingWorksheetShipmentExt worksheetShipmentExt = worksheetShipment?.GetExtension<SOPickingWorksheetShipmentExt>();

if (worksheetShipmentExt.UsrPickListPrintCount >= 2)
{
if (Base.worksheet.Ask("Do you want to reprint this pick list?", MessageButtons.OKCancel)!= WebDialogResult.OK) return a.Get();
}

//update print count
worksheetShipmentExt.UsrPickListPrintCount = worksheetShipmentExt.UsrPickListPrintCount ?? 0;
worksheetShipmentExt.UsrPickListPrintCount = worksheetShipmentExt.UsrPickListPrintCount + 1; Base.shipmentLinks.Cache.SetValueExt<SOPickingWorksheetShipmentExt.usrPickListPrintCount>(worksheetShipment,worksheetShipmentExt.UsrPickListPrintCount);
Base.shipmentLinks.Update(worksheetShipment);
Base.Save.Press();
}
}

return Base.printPickList(a);
}

#endregion
}

 

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