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, ...
Suggested Answer

Cannot create a record in MB500SalesTable. The record already exists

(1) ShareShare
ReportReport
Posted on by 6
Hello Experts,
 
I have a requirement to add a custom fields into the standard SalesTable. As per the Microsoft best practice , we cannot add more than 10 fields into the standard fields. 
 
To fulfill the requirement I have created a extension table named as MB500SalesTable. I have attached this table as a datasource to the SalesCreateOrder form. This form is used to create a new sales order. For testing purpose i have extended this form and added one field to that form. But, I'm getting an error while creating a sales order stating that "Cannot create a record in MB500SalesTable. The record already exists". 
 
 
I have upload the screenshots of the objects and code I have written.
 
Note: For MB500SalesTable insert and update methods I have written the following code. 

public class MB500SalesTable extends common

{   public void insert()

   {if (this.SalesTable)

       {super();}}

   public void update()

   {if (this.SalesTable){super();}  }

}

Can anyone tell what did I miss. Kindly help me to create a sales order 

 
 
 
 
Categories:
Screenshot 2025-0...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    Navneeth Nagrajan Profile Picture
    2,430 Super User 2025 Season 2 on at
    Hi CU20060538-1,
     
    Read the hands on exercise lab that you are referring to. Would prefer doing this through data entities. 
     
    SysExtensionSerializer is a helper class that is used to find tables that are based on a table buffer and an extension table buffer that comes from the the joined data source. SysExtensionSerializerExtensionMap is used to map all extension tables.
     
    Suggestion:
    If you are using the hands on lab to create a new sales order then would recommend the following:
     
    1. In your init() method you need to call SalesTable instead so the FormDataSource_ds code will be.
    FormDataSource salesTable_ds = formRun.dataSource(formDataSourceStr(SalesTable,SalesTable)); 
    If you use SalesTableCreateNew it is going to retrieve an empty record. 
     
    2. Similarly, in your write() method you need to amend this change.
    FormDataSource Mb500SalesTable_DS = this.formRun().dataSource(formDataSourceStr(SalesTable,SalesTable)); 
     
    Also, in your SalesTable you can add a code like this if you are looking to use the SysExtensionSerializerMap
     
    public MB500SalesTable mb500SalesTable()
    {
     return this.SysExtensionSerializerMap::getExtensionTable(tablenum(MB500Table);
    }
     
    And write an extension on insert() method like this.
     
     
    public final class SalesTable_Extension
    {
       void insert()
       {
             next insert();
             
             MB500SalesTable mb500SalesTable = SalesTable.mb500SalesTable()
             mb500SalesTable.SysExtensionSerializerExtensionMap::insertAfterBaseTable(SalesTable);
       }
    }
     
     
     
     
    Understand you are doing a hands on lab but if you are doing this example in realtime, then your code needs to go into the OnClicked Event hander on the Sales Order new button.
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(SalesTableListPage, NewSalesOrder), FormControlEventType::Clicked)]
    public static void NewSalesOrder_OnClicked(FormControl sender, FormControlEventArgs e)
    {      
    //Code snippet and custom field actions will go in here. 
    }
     
    In addition to this, there will be additional code that you can add based on your requirement.
     
    Hope this helps. Happy to answer questions, if any.
     
     

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 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans