Question

Customer Location Sequence

  • 20 September 2023
  • 0 replies
  • 84 views

Userlevel 2

Good day,

I am working on a sequence for customer location that executes when the button is pressed. I can’t use AutoNumber Attribute because I need to be able to manually enter customer locations as well. The sequence works correctly in Numbering sequences screen, but in Customer Location I am having 2 issues, when I press the button and does the sequence, then I press the save button and it does save the new record but the save button stills available to be pressed even when I already saved and didn’t made any changes, and the other issue I will explain it with an example, if I made a customer location with the sequence, and the number is 1579, I save the record and then if I need to create another customer location for the same customer I press + and the button and what happens is that in the numbering sequence screen it does well the sequence, now the Last number is 1580 and if you save the location it saves 1580 but in customer location screen the button is retrieving the first customer location to the LocationCD field, which means that even if you keep pressing the button and the sequence keeps going up, what you see in the LocationCD field is 1579.

Not sure if I need to attempt to refresh or do something with the cache, I have tried a few ways and haven’t been able to resolve it,

 I would appreciate some assistance.

Thank you.

  public class CustomerLocationMaint_Extension : PXGraphExtension<PX.Objects.AR.CustomerLocationMaint>
{
public int lastNumber = 0;

public PXAction<Location> ClSeqNum;
[PXLookupButton(DisplayOnMainToolbar = false, CommitChanges = true)]
[PXUIField(DisplayName = "AUTO", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true)]
//Action method
protected virtual void clSeqNum()
{
lastNumber = 0;


NumberingMaint numberingGr = PXGraph.CreateInstance<NumberingMaint>();
CustomerLocationMaint clGr = PXGraph.CreateInstance<CustomerLocationMaint>();
NumberingSequence numbering = SelectFrom<NumberingSequence>
.Where<NumberingSequence.numberingID.IsEqual<@P.AsString>>
.View.Select(numberingGr, "LOCATION");



if (numbering != null)
{
lastNumber = int.Parse(numbering.LastNbr) + 1;


var row = Base.Location.Current;


Base.Location.Cache.SetValueExt<Location.locationCD>(row,
lastNumber.ToString());

Base.Location.Cache.SetValueExt<Location.descr>(row, "NEW");

Base.Caches[typeof(Location)].Update(row);


Base.Location.View.RequestRefresh();

numbering.LastNbr = lastNumber.ToString();

numberingGr.Caches[typeof(NumberingSequence)].Update(numbering);

numberingGr.Actions.PressSave();


lastNumber = 0;
}

}



}

 


0 replies

Be the first to reply!

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