Skip to main content
Solved

Add counter for the number of times pick list printed

  • Jun 27, 2022 12:34 PM UTC
  • 4 replies
  • 228 views
  • Translate All

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
}

 

View original

4 replies

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Jun 27, 2022 1:05 PM UTC

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

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

 

 

Translate

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Jun 27, 2022 2:20 PM UTC

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

Translate

param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Jun 28, 2022 4:58 AM UTC

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

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • Jun 28, 2022 5:58 AM UTC

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
}

 

Translate