To get Next RecId for a table:

To get the next recid for custtable,use the below code …
before printing the recid , suspendrecids() has to be call then after printing recid removeRecIdSuspension() method should be call….

static void getNextRecIdAX40(Args _args)
//Table that stores record ids details for tables
SystemSequences systemSequences;

//Class that handles Record id generation
SystemSequence systemSequence = new SystemSequence();

select firstonly systemSequences
where systemSequences.tabId == Tablenum(custtable);

info(strFmt(‘Next record id: %1’, systemSequence.reserveValues(systemSequences.minVal, systemSequences.tabId)));


3 thoughts on “To get Next RecId for a table:

  1. Very useful, thanks!

    One comment though: this reserves the returned rec id for insert. The next actual inserted recid in the table will be the returned rec id + 1. Not a big deal, at least not in the situation I’m using this code for, but it is something to keep in mind.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s