Hey all, I have an issue within Project Entry I’m a bit stumped on. We have a BPM that fires when you go to create a new Variant, it is supposed to auto-update the Variance Reference ID (VarRefID) sequentially. If a project has no variant, it runs fine and adds the VarRefID as expected. If you add a 2nd, again this works fine. If you attempt to add an additional variant it attempts to overwrite the most recent VarRefID.
This is ONLY occurring within our Live DB, I’m unable to re-produce the error within our TEST environment, (I will be restoring a newer backup of our Live DB to Test shortly, just waiting on access). I’ve checked the BPM in both the Live and Test environments, they are identical.
To my knowledge there has not been a recent update. To expand on that, I am actually new to this environment as of a week ago. So I’m actually still waiting on access to the Epicor App server to verify when the last update was.
When you pull that lastRefID in the foreach loop you’re not ensuring it’s actually the last one in any way. You’re banking on getting lucky that the last iteration of the foreach gets you the actual row you want.
You need some order by or something else to key off of.
The ordering of records could be different in different DBs. Especially when you start getting into Views vs Tables, stuff can get weird.
Tighten up the logic on that foreach loop and I think you’ll be good.
Hmm that may do the trick but I’m not 100% sure. Looks like that pconvar table doesn’t give you a whole lot to work with (I was thinking it would have something like a system generated line number but it doesn’t).
Instead of trying to identify the last “row/sequence” you might consider doing a count of pconvar rows where projectID = projectID, and then increment 1 to the count to get your next VarRefID…?