Skip to main content

Notifications

Microsoft Dynamics GP (Archived)

GP Web Service Extension Assembly Update of GP Customer Information

Posted on by 40

I have implemented a GP Web service extension assembly registered to update the Email address in the GP 2010 SY01200 table, when the email address is altered in CRM 2011.

Before I go any further, the environment that I am working on is as follows:

1. CRM 2011

2. GP 2010

3. My worked is based on the following MSDN articles regarding extending the GP Web service using custom assemblies:  msdn.microsoft.com/.../cc508802.aspx

Step 1: I registered my assemblies code for the [Customer] object under the [Updating] event in the [BusinessObjectsFile.config]. Please refer to figure 1 below for some sample code:

Step 2: I Created an extension assembly that updates the SY01200 table. To make sure that this code included in the assembly works; I tested the sql statements in a seperate application linking to my GP database. It did update the SY01200 table. However when my custom assembly executes, the code fails. Please refer to figure 2 as shown at the bottom of this question.

PROBLEM:

* When my custom assembly`s code runs, I get an exception (as viewed from the GP Web/serv exception console) which is as follows:

-----------------------------------

Exception Type:                      Object Type:                                                       Operation:

Validation                                Microsoft.Dynamics.GP.Customer                 Create

-----------------------------------

Further details are as follows:

------------------------------------------------------

A validation exception has occurred.
Validation Errors:
- CustomerKey already exists and the UpdateIfExists flag is set to not allow updates.

-------------------------------------------------------

Figure 1 --> The event registration code added to the [BusinessObjectsFile.config]

<DictionaryEntry>

     <Key xsi:type="xsd:string">Microsoft.Dynamics.GP.Customer</Key>

     <Value xsi:type="BusinessObjectConfiguration">

       <Event>

         <EventName>Updating</EventName>

         <EventHandlerType>

           <Type>Microsoft.Dynamics.Common.BusinessObjectUpdateEventHandler</Type>

           <Assembly>Microsoft.Dynamics.Common</Assembly>

         </EventHandlerType>

         <EventHandler>

           <SoftwareVendor>DEVCOMPANY01</SoftwareVendor>

           <Type>EmailAddressExtension.EmailAddressProviderExt</Type>

           <StaticMethod>UpdateCustomerEmail</StaticMethod>

           <Assembly>EmailAddressExtension</Assembly>

           <Execute>true</Execute>

         </EventHandler>

       </Event>

     </Value>

</DictionaryEntry>

Figure 2 --> The ado.net sql update statement. I tested this code in a seperate application and it then successfully updates the SY01200 table.

I have tested this code in a separate console application to test is it does update the GP database, which it does without complaining about duplicate customerkey.

// The SQL statement to update SY01200 table for the Customer (Master_Type = 'CUS')

string updateStatement = "UPDATE SY01200 SET INET1='" + email + "' WHERE Master_Type = 'CUS' AND Master_ID = '" + customer.Key.Id.Trim() + "'" +

                   "AND ADRSCODE = '" + adrscode + "'";

I would appreciate it if anybody could shed some light regarding this issue,.

Thanks

*This post is locked for comments

  • Chrisprg Profile Picture
    Chrisprg 40 on at
    RE: GP Web Service Extension Assembly Update of GP Customer Information

    Hi Steve

    Thanks for your reply. I am not currently working on this issue any more, but I will let you know as soon as I receive feedback with regards to this solution.

    Your logic seems correct though and I am sure that this will solve the problem.

    cheers

  • Suggested answer
    Steve Kubis Profile Picture
    Steve Kubis on at
    RE: GP Web Service Extension Assembly Update of GP Customer Information

    I suspect that your issue is the event that you're using.

    In the sample that you're using as an example, a separate table is being updated. In your case, you're actually updating a Dynamics GP table. It seems like you're interfering with the GP update operation.

    I would try using the "Updated" event instead of the "Updating" event. The Dynamics GP process that's updating the record should have finished by the time the "Updated" event is run, so then you should no longer be conflicting with the GP operation.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans