Solved

Cache not retaining value set in method - what can I look at to solve this?

  • 16 November 2022
  • 4 replies
  • 85 views

Userlevel 7
Badge +5

I’ve been puzzling through this issue and I’m not sure where to go for figuring this out.

Action button on Sales Order Maint will

  1. Create a record in a custom table.
  2. Load up the graph for that custom table and press an action button.
  • Custom graph passes it’s record into a method to be updated.
  • Custom graph passes it’s record into a second method to be updated. But it loses changes coming out of the second method. It’s almost like the record is passed into the second method as a copy instead of a reference to the record.

If, however, I open up the graph for the custom table and click on the action button - the above process works just fine.  My Order Entry customization is literally pressing the action button on the custom graph.

I’m using this form for updating the field values to try and ensure that the correct cache is being updated.

myCustomGraph.Caches[typeof(MyDAC)].SetValueExt<MyDAC.myField>(myRecord, SomeValue);

and

myRecord = myCustomGraph.Caches[typeof(MyDAC)].Update(myRecord);

 

So I think I’m curious on what I might look out for to figure out why myRecord is losing/forgetting changes when being run from the Order Entry button but retains it when running the process from the Custom Graph button.

icon

Best answer by Django 30 November 2022, 18:29

View original

4 replies

Userlevel 7
Badge +17

Hi @ddunn  Is it possible to share the code?

Userlevel 5
Badge +1

I have seen this happen with SQL Autonumber keys on the child table. During the insert process but before the cache is persisted the ID field is a large negative number, if you pass that record into another graph it doesn’t have the same understanding of what the negative number means and so it basically drops the changes as there is no record in the DB with that index. when you run it locally it works as the graph understands you are inserting so it saves normally.

I would, if you can, persist before calling the second graph so you have a proper ID, assuming I am correct :)

Userlevel 7
Badge +5

I’ll add some code shortly. I just want to make sure that you’re not having to wade through too much.

Fortunately this doesn’t have any child records - I’m just passing an existing record through a handful of methods to have some fields updated and then save it. This has to be some sort of scoping issue but I also know that the cache can work in mysterious ways (but shouldn’t).

I’ll report back soon.

Userlevel 7
Badge +5

This appears to have resolved itself.  I’ll file this under ‘evil spirits’.

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