web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to update the Next value of Number Sequence using OData

(0) ShareShare
ReportReport
Posted on by 10

Hi,

I'am trying to update the Number Sequence "Next" value using OData

var sequence = context.SequenceTables.Where(x => x.NumberSequenceCode == "Inve_184" && x.Company == "USMF").Select(e=> e);

DataServiceCollection<SequenceTable> dscSequence = new DataServiceCollection<SequenceTable>(sequence);

foreach(var i in dscSequence)
{
i.Next = i.Next + 1;
context.UpdateObject(i);
}
context.SaveChanges(SaveChangesOptions.PostOnlySetProperties);

It throws an error that I can't update it when the Number Sequence is "In Use"

Is there any way to update the Next value via OData or REST API?

Regards,

John Carlo

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi John,

    Why do you want to change the Next value? What is your business requirement?

  • Carlo333 Profile Picture
    10 on at

    Hi André,

    We are trying to automate Inventory Adjustment Journal header and Lines Import.

    First thing is we need an inventory adjustment journal, but after creating an inventory adjustment journal via OData. it won't increment the "Next" value of the number sequence associated with it.

    We want to create an Inventory adjustment Journal via OData at the same time the number sequence should increment so we can still manually create the journal if needed which right now throws an error "Journal already exist" because the number sequence didn't Sync or increment when we use OData

    Regards,

    John Carlo

  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi Sir,

    The NumberSeqRecordFieldHandler class enableNumberSequenceControlForField will generate the value of the field we pass in the parameters with the next value from the sequence we select. 

    You can try it in combination with OData:

    e.g.

    Hope it help you.

    regards

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    It seems that you're trying tio mask a bug rather than fixing it.

    How are you assinging the number from number sequence? If it's done correctly, the number sequence will be updated, as in all cases in the whole system where number sequences are used. Don't you actually assign the number by yourself, instead of using the number sequence framework.

    And by the way, please use Insert > Insert Code (in the rich formatting view) to paste source code to the forum.

  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Carlo,

    Please explain how you are retrieving and set the number sequence value. Have you tried leaving the journalID field empty? I think it should then allocate a new journal number during the insert action.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans