Skip to main content
Answer

Add counter for the number of times pick list printed

  • June 27, 2022
  • 4 replies
  • 170 views

param2022
Jr Varsity II
Forum|alt.badge.img

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
}

 

Best answer by Naveen Boga

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
}

 

4 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • June 27, 2022

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

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

 

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • June 27, 2022

@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.


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • June 28, 2022

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • June 28, 2022

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
}