
I want to implement item number generation based on the number sequence configured for the selected Item Group.
In standard D365 FO functionality, for Customers and Vendors, it is possible to assign a number sequence to a Customer Group or Vendor Group. When creating a new customer or vendor, if the selected group has a number sequence configured, the newly created customer or vendor account number is generated from that group's number sequence.
During my analysis:
I debugged the vendor number sequence logic and observed that when a new vendor is created, if the selected Vendor Group has a number sequence assigned, the vendor account number is generated from that specific number sequence.
While trying to implement similar functionality for Item creation, I noticed that the item creation form (EcoResProductCreate) is used when creating a new item, and this form does not contain any datasource.
I mention the datasource because I observed that the numberSeqFormHandler() method in the Vendor form is responsible for handling number sequence generation based on the Vendor Group setup.
Inside this method, the standard implementation passes VendTable as the datasource when creating the NumberSeqFormHandler instance. Therefore, when trying to replicate the same approach for item number generation, I am unable to do so because the EcoResProductCreate form does not have a datasource.
In the below standard code(which is called when the vendor group or customer group is modifeid while creating new vendor or customer), the newForm() method is called from within numberSeqFormHandler(), and the datasource is passed as a parameter. Since EcoResProductCreate has no datasource, I am facing difficulties implementing the same pattern for item number generation.
Could you please advise whether there is another recommended approach to achieve this requirement? Are there any standard classes or methods that can be used instead of numberSeqFormHandler() for this scenario? Alternatively, would it be appropriate to add an InventTable datasource to the EcoResProductCreate form to support this functionality?