# NextValue API and REST

**URL:** <https://www.epiusers.help/t/nextvalue-api-and-rest/73566>\
**Category:** Epicor ERP 10\
**Tags:** e10\
**Created:** [December 10, 2020, 9:19pm UTC](https://www.epiusers.help/t/nextvalue-api-and-rest/73566 "2020-12-10T21:19:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krum](https://www.epiusers.help/letter_avatar_proxy/v4/letter/k/a88e57/32.png) [@krum](https://www.epiusers.help/u/krum)\
**Post date:** [December 10, 2020, 9:19pm UTC](https://www.epiusers.help/t/nextvalue-api-and-rest/73566/1 "2020-12-10T21:19:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![krum](https://www.epiusers.help/letter_avatar_proxy/v4/letter/k/a88e57/32.png) [@krum](https://www.epiusers.help/u/krum)\
**Post date:** [December 12, 2020, 1:28am UTC](https://www.epiusers.help/t/nextvalue-api-and-rest/73566/2 "2020-12-12T01:28:52Z")

</div>

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.");  
  }  
}
```
