It has been a while since I used the global sequence library today I had to spend way too much time on it cause I couldn’t figure out how to use it.
I wanted to set my sequence to a specific current value and also (later) use it to get the next value the documentation I had looked like this to generate the “next” value
// Ice.Lib.NextValue.dll
var nv = new Ice.Lib.NextValue(Db);
int seqNum = nv.GetNextSequence("CustIDSeq");
Simple enough looks like you instantiate a NextValue object and then call GetNextSequence. However setting a vale (current) I couldn’t find. That object had a method called Set() which takes a Generic Table T and a Target Row… which is confusing at best. After much poking and prodding I broke out the decompiler and here’s what I found
Indeed a NextValue instance does have a Set Method which takes a generic table and a target row and I don’t really know what that does. But then I found it also has a method called “SetSequenceCurrentValue” which takes Db context, Sequence ID, and the value you want… BINGO!!
But wait… its a Static Method no wonder I couldn’t find it. So to set the value of a Sequence you call the Static Method SetSequenceCurrentValue using a Satic refererence as shown
// Set sequence value (static reference only... cause... #Reasons
Ice.Lib.NextValue.SetSequenceCurrentValue(Db,"MySequence",1234);
But then if you want to get the next sequence or increment the sequence by one you need an instance of the NextValue class to invoke the GetNextSequence method…
var nv = new Ice.Lib.NextValue(Db);
int seqNum = nv.GetNextSequence("MySequence");
When developers go to hell, they are condemned to maintain code they wrote 5 years ago for eternity.
A long time ago in a source control system far far away, I believe this was one of the very first projects I wrote when we started converting the server from OpenEdge to .NET Framework (circa 2010?)
I’m not even going to attempt to explain how one method ended up as static and one didn’t. And my lawyer said it was best to not comment on the state of my sobriety at the time
Setting the current value of a sequence is something that is seldom needed. That’s perhaps why it took over a decade for anyone to notice. If you care enough, create a ticket with support and we can give that API some love.
Other than the cosmetic aspect of the API, I will vouch for it working as advertised.
A long long time ago right when I got starting doing Epicor stuff I wrote a billing interface called “Invoice a Tron”… I was just learning C# and I had recently learned how to make custom controls. So I decided to make a new Custom control for every feature in that thing… it was a work of art…
Imagine an application with 10 tabs or so where every tab is a custom control maintained in a different project all put together like an insane puzzle. I think they finally killed that monster, one can only hope nobody took a look at the code base
Not only was each tab a custom control, but all the business logic was INSIDE THE CONTROLS!!! It’s nice to look back and confirm that we were every bit as smart as we thought we were at the time. =)
That said, I’ll never forget when we wrote a whole purchase order import program that ran right on the first test. Pretty sure that was the only time we ever did such a thing.