Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

(0) ShareShare
ReportReport
Posted on by 585

Hi,

I am trying to create a Sales Order using the Web Service API. I receive an error about a phone number:

Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

This field appears to be in the customer address table. Where is this field and how do I fill it in? Here is my code:

public CustomerAddressKey CreateCustomerAddress(CustomerKey customerK)
{
CustomerAddressKey customerAddressKey;
CustomerAddress customerAddress;

// Create a customer key to specify the customer
//customerKey = new CustomerKey();
//customerKey.Id = "AARONFIT0001";

// Create a customer address key
customerAddressKey = new CustomerAddressKey();
customerAddressKey.CustomerKey = customerK;
customerAddressKey.Id = "BILLING";

// Create a customer address object
customerAddress = new CustomerAddress();
customerAddress.Key = customerAddressKey;
// Populate properties with address information
customerAddress.Line1 = "11403 45 St. South";
customerAddress.Line2 = "Billing Dept.";
customerAddress.City = "Chicago";
customerAddress.State = "IL";
customerAddress.PostalCode = "02452";
customerAddress.CountryRegion = "USA";
customerAddress.Phone1 = new PhoneNumber { CountryCode = "1", Extension = "781", Value = "1234567" };
// Get the create policy for the customer address

// Create the customer address
wsDynamicsGP.CreateCustomerAddress(customerAddress, context, createCustomerAddress);
return customerAddress.Key;
// Close the service
//if (wsDynamicsGP.State != CommunicationState.Faulted)
//{
// wsDynamicsGP.Close();
//}
}

*This post is locked for comments

  • Kevin Day Profile Picture
    Kevin Day 610 on at
    RE: Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

    Just something else to check on this error in case someone else gets it.  I was getting this using eConnect (which is what Web Services eventually uses too), but it was only for one Customer on a SOP Invoice.  It turns out that the Customer had a bad address ID.  It had an address ID of "MAIN" but that address ID did not exist in the RM00102 (Customer Address) table.  So that was what was causing the error.  I'm guessing that the underlying query to set defaults is left joining to the address table on that Ship to Address ID, which didn't exist, and it tried to insert a NULL.  I ran Check Links and it hinted about that having missing records.  Just deleted the bad address ID and it worked after that.

  • Marco Lee Profile Picture
    Marco Lee 20 on at
    RE: Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

    I was finally able to reolve this. If creating an address for the Sales Order you need to assign the ShipToAddressKey for EVERY item.

    Here is the gump'd down code.

    SalesOrderLine[] lines;

    foreach (SalesOrderLine LineItem in SalesOrder.SalesOrderLines)
    {
           salesOrderLine.ShipToAddressKey = salesOrder.ShipToAddressKey;
           lines[iCurrLine] = salesOrderLine;
    }


    salesOrder.Lines = lines;

    CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);

  • Marco Lee Profile Picture
    Marco Lee 20 on at
    RE: Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

    Hello Sanjay, I don't know if your response answers the question. Like jmawebtech, I am having the same issue with Web Services, not eConnect. The solution you provided requires the use of eConnect.

    We have just upgraded from GP10 to GP 2013. After finally getting Web Services working, I recieve the following error:

     

    Stack Trace:

       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)

       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

       at Microsoft.Dynamics.GP.eConnect.EntityMessageProcessor.ExecuteSqlCommands(XElement transactionNode, EntityMessage message)

       at Microsoft.Dynamics.GP.eConnect.eConnectMethods.ProcessMessageImport(EntityMessage message)

       at Microsoft.Dynamics.GP.eConnect.eConnectMethods.EntityImportImplementation(String connectionString, String sXML, Boolean isTransaction)

       at Microsoft.Dynamics.GP.eConnect.eConnectMethods.CreateEntity(String connectionString, String sXML)

       at Microsoft.Dynamics.GP.EConnectAdapter.ExecuteWrite(String xml, String typeName, Context context, BusinessEvent eventType, BusinessObjectEventArgs args, EventLocation eventLocation)

       at Microsoft.Dynamics.GP.EConnectAdapter.Create(BusinessObject businessObject, Context context, Policy policy)

       at Microsoft.Dynamics.GP.GreatPlainsBusinessService.PersistForCreate(BusinessObject businessObject, Context context, Policy policy)

       at Microsoft.Dynamics.Common.BusinessService.Create(BusinessObject businessObject, Context context, Policy policy)

     

  • Suggested answer
    RE: Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

    Check out this response

    community.dynamics.com/.../234510.aspx

    Cheers!

    Sanjay

  • John Lowther Profile Picture
    John Lowther 5,122 on at
    RE: Cannot insert the value null into column Print_Phone_NumberGB table Two.db.SOP10200

    What version of GP are you on?

    I looked at the SOP10200 table in GP2010R2 and did not see a field named "Print_Phone_NumberGB"; however, I did not see a field anywhere in the table that did allow nulls. So, as just a guess, and I stress the "just a guess" part try adding the line "customerAddress.Print_Phone_NumberGB = "try different values here" and see if that helps.

    Just a shot in the dark,

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans