Share via


Saving a row

To save a new row in a table, set the fields in the table to the values you want to save. Then use the Save() method to save the new row in the table. The following C# example adds a new row to the GL_Account_Category_MSTR table. It sets the values for the fields in the table, then saves the new row.

// Variable for any table operation error
TableError err;

// Create a reference to the table
GlAccountCategoryMstrTable CategoryMasterTable;
CategoryMasterTable = Dynamics.Tables.GlAccountCategoryMstr;

// Set the fields in the table
CategoryMasterTable.AccountCategoryNumber.Value = (short)49;
CategoryMasterTable.AccountCategoryDescription.Value = "Profit Sharing";

// Save the new row
err = CategoryMasterTable.Save();

if(err == TableError.Duplicate)
{
    MessageBox.Show("Account category already exists");
}

// Close the table
CategoryMasterTable.Close();