NextValue API and REST

I’m using the NextValue API to assign sequential IDs. Now we need to obtain an ID from the same sequence during the order process on a website, before the order exists in Epicor. So I’m trying to think of a way to use the NextValue API in something accessible through the REST API. I don’t have access to Epicor Functions.

The best idea I’ve come up with is a post-processing directive on GetRows on a UD table. The caller would get a particular row and the BPM would invoke NextValue and set one of the columns. Is this crazy talk?

This was easier than I thought. No need to touch callContextBpmData. I just added a post-processing directive on UD05.GetRows that looks at whereClauseUD05 and conditionally synthesizes a row.

if(whereClauseUD05.Contains("Key1='NextValue'"))
{
  var rx = new Regex("Key4='(.+)'", RegexOptions.Compiled);
  var m = rx.Match(whereClauseUD05);
  if(m.Success)
  {
    var prefix = m.Groups[1].Value.ToUpper();
    var seq = prefix + "_c";
    var nv = new Ice.Lib.NextValue(Db);
    int v = nv.GetNextSequence(seq);
    var s = prefix + v.ToString("000000");
    var row = new UD05Row() { Number01 = v, Character01 = s };
    ttUD05.Clear(); // should already be empty
    ttUD05.Add(row);
  }
  else
  {
    throw new Ice.BLException("Missing prefix in a NextValue request.");  
  }  
}