Question Status

Verified
Mike N Ike asked a question on 31 Jan 2013 8:55 AM

I'm getting this error when I try to create a new customer from an AIF document web service. This was working before we upgraded to R2.

Here is my C# code that I am using to call the web service:

               MyService.AxdEntity_CustTable customer = new MyService.AxdEntity_CustTable();

                //
                MyService.AxdEntity_DirPartyPostalAddressView postalAddress = new MyService.AxdEntity_DirPartyPostalAddressView();
                postalAddress.Street = "123 Anystreet";
                postalAddress.City = "Anytown";
                postalAddress.State = "TX";
                postalAddress.ZipCode = "79999";
                postalAddress.CountryRegionId = "USA";
                postalAddress.StreetNumber = "123";
                postalAddress.RecIdSpecified = false;
                postalAddress.Roles = "Invoice";

                MyService.AxdEntity_DirParty_DirPerson dirParty = new MyService.AxdEntity_DirParty_DirPerson();

                dirParty.DirPartyPostalAddressView = new MyService.AxdEntity_DirPartyPostalAddressView[] { postalAddress };
                dirParty.PersonName = new MyService.AxdEntity_PersonName[] { new MyService.AxdEntity_PersonName() { FirstName = "MySecond", MiddleName = "Test", LastName = "Person" } };


                MyService.AxdEntity_DirPartyContactInfoView emailInfo = new MyService.AxdEntity_DirPartyContactInfoView();
                emailInfo.Type = MyService.AxdEnum_LogisticsElectronicAddressMethodType.Email;
                emailInfo.Roles = "Invoice";
                emailInfo.Locator = "anybody@mail.org";
                emailInfo.IsPrimary = MyService.AxdEnum_NoYes.No;
                emailInfo.LocatorExtension = "";
                emailInfo.LocationName = "Primary Email";

                MyService.AxdEntity_DirPartyContactInfoView phoneInfo = new MyService.AxdEntity_DirPartyContactInfoView();
                phoneInfo.Type = MyService.AxdEnum_LogisticsElectronicAddressMethodType.Phone;
                phoneInfo.Roles = "Invoice";
                phoneInfo.Locator = "800-867-5309";
                phoneInfo.IsPrimary = MyService.AxdEnum_NoYes.Yes;
                phoneInfo.LocatorExtension = "456";
                phoneInfo.LocationName = "Primary Phone";


                dirParty.DirPartyContactInfoView = new MyService.AxdEntity_DirPartyContactInfoView[] { emailInfo, phoneInfo };

                customer.DirParty = new MyService.AxdEntity_DirParty_DirPerson[] { dirParty };

                customer.action = MyService.AxdEnum_AxdEntityAction.create;
                customer.SuppItemGroupId = "Retail";
                customer.CustGroup = "Retail";
                customer.LineDisc = "Retail";
               
                MyService.AxdEntity_CustTable[] cust = new MyService.AxdEntity_CustTable[] { customer };

                MyService.EntityKey[] keys = client.create(context, cust);

                foreach (MyService.EntityKey key in keys)
                {
                    MessageBox.Show("New Customer completed.... Field = " + key.KeyData[0].Field + "; Value = " + key.KeyData[0].Value);
                }

 

Reply
Verified Answer
Mike N Ike responded on 2 May 2013 7:08 AM

I had to get a hot fix from Microsoft on this one.  Here is a portion of the email that they sent to me:

The DirPerson’s update() will be called after inserting records in DirPerson, LogisticsLocationPostalAddress and DirPersonName.

To fix the issue, the DirPerson’s record should be reread before updating it.

Code modified:

\Classes\DirPartyServiceOp\processSaveForDirParty()

private static boolean processSaveForDirParty(AxdStack _axdStack,

AxdRecordProcessingContext _recordProcessingContext = AxdRecordProcessingContext::BeforeAnyChildRecordsProcessed,

AxInternalBase childRecord = null)

{

.

axDirPersonName2 = childRecord;

person = axDirPerson.currentRecord();

person.reread();

person.updateName(axDirPersonName2.currentRecord());

return true;

.

}

Reply
Yasir Godil responded on 2 May 2013 1:54 AM

Hi,

Were you able to resolve this issue ? I am also getting the same error when creating a customer (person type) using AIF. However, when I don't include address the customer gets created but I would like to create customer using Address entities as well.

if you were able to solve this problem, please share the remedy here.

Thank you

Reply
Bilal Issa responded on 2 May 2013 3:08 AM

Hi ,

please use

customer.createDirParty().add(dirParty ); and comment the code customer.DirParty = new MyService.AxdEntity_DirParty_DirPerson[] { dirParty };

and then

customer.create();

Regards,

Bilal

Reply
Verified Answer
Mike N Ike responded on 2 May 2013 7:08 AM

I had to get a hot fix from Microsoft on this one.  Here is a portion of the email that they sent to me:

The DirPerson’s update() will be called after inserting records in DirPerson, LogisticsLocationPostalAddress and DirPersonName.

To fix the issue, the DirPerson’s record should be reread before updating it.

Code modified:

\Classes\DirPartyServiceOp\processSaveForDirParty()

private static boolean processSaveForDirParty(AxdStack _axdStack,

AxdRecordProcessingContext _recordProcessingContext = AxdRecordProcessingContext::BeforeAnyChildRecordsProcessed,

AxInternalBase childRecord = null)

{

.

axDirPersonName2 = childRecord;

person = axDirPerson.currentRecord();

person.reread();

person.updateName(axDirPersonName2.currentRecord());

return true;

.

}

Reply
Yasir Godil responded on 2 May 2013 6:51 PM

Okay, so it worked. however, it is creating 2 postal address records for me. i am only providing one record but it is creating 2 records at the same time with same details.

Reply
Yasir Godil responded on 6 May 2013 2:47 AM

Okay, so it worked. however, it is creating 2 postal address records for me. i am only providing one record but it is creating 2 records at the same time with same details.

Any idea ?

Reply
Apex InfoTech - Bijan Gofranian responded on 24 Feb 2014 10:32 PM

Thank you Mike. I can confirm that this bug has not been fixed on AX 2012 R2 CU6. The person.reread() certainly did fix the "Dir person update conflict" error.  After adding the fix Customer, Address and Contacts were created correctly for me.

Thank you for sharing.

Bijan Gofranian

Reply