how to automaatically update the sequence of the d...
# ask-stanley-ai
n
how to automaatically update the sequence of the document numbers if we have duplicate JE number without reversing the JEs
c
AI generated answer (using internal Slack threads):
To automatically update the sequence of the document numbers if you have duplicate JE numbers without reversing the JEs, you can use a SuiteScript. The script would need to be scheduled or map/reduced to run through your JEs and check for duplicates. If a duplicate is found, the script can increment the document number and save the record. Here is a basic example of how this might look:
Copy code
javascript
var searchResult = search.create({
   type: "journalentry",
   filters:
   [
      ["number","is", duplicateNumber]
   ],
   columns:
   [
      search.createColumn({name: "internalid", sort: search.Sort.ASC}),
      "number"
   ]
}).run().getRange(0, 100);

for (var i = 0; i < searchResult.length; i++) {
   var record = record.load({
      type: 'journalentry', 
      id: searchResult[i].getValue('internalid')
   });
   var currentNumber = record.getValue('number');
   record.setValue('number', currentNumber + 1);
   record.save();
}
This script will load each JE with the duplicate number, increment the number by 1, and then save the record. Please note that this is a simplified example and may need to be adjusted to fit your specific needs. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.79403019
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.792345464
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.789484918
Please provide your feedback on this answer.