Skip to main content

...or perhaps I’m not using it properly. 

I’m experimenting with TimeStamp to understand Acumatica’s locking better.

I’ve created the following code, a simple button call the press save.

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{

public static bool IsActive() => true;
public PXAction<SOOrder> CheatSave;
vPXButton(CommitChanges = true)]
ePXUIField(DisplayName = "Cheat Save")]
protected void cheatSave()
{
var a = Base.TimeStamp;
Base.SelectTimeStamp();
var b = Base.TimeStamp;
Base.Actions.PressSave();
}
}

The button appears on the main menu. 

When I go to an existing order, update the Description and press ‘CHEAT SAVE’ it works, the change is saved.

If I go to an existing order, update the Description, then update the description in SQL (using update SOOrder set OrderDesc = 'Z' where OrderNbr = 'SO023847'), and press ‘CHEAT SAVE’ I get the following message. 

“Error: Another process has updated the 'SOOrder' record. Your changes will be lost.”

This message would be expected but I thought that calling Base.SelectTimeStamp would refresh the TimeStamp value stored against the graph and allow the update to be saved. By stepping through the code and checking variables a and b, I can see that the Base.TimeStamp value is refreshed after I updated the record from SQL.  
Have I misunderstood what SelectTimeStamp should do?

 

@stephenward03 

The tstamp field in SOOrder is defined in the following way:

 

That means that updating the tstamp in the graph itself is not enough to cheat the save here. There is also the value in the DAC itself that is checked too. 


Thanks @Dmitrii Naumov, I didn’t know there was an option to update how the TimeStamp worked. 

I’ve updated the code and the cheat’s save is working now. Though, I’ll try ever to use it!

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{

public static bool IsActive() => true;

#region Event Handlers

public PXAction<SOOrder> CheatSave;

/PXButton(CommitChanges = true)]
)PXUIField(DisplayName = "Cheat Save")]
protected void cheatSave()
{
var a = Base.TimeStamp;
Base.SelectTimeStamp();
var b = Base.TimeStamp;
Base.Document.Current.tstamp = b;
Base.Document.UpdateCurrent();
Base.Actions.PressSave();
}
}

 


Reply