Notifications
Announcements
No record found.
Hi,I'm trying this but I'm getting this Error:Unable to write data to entity accounts.Writes to CustCustomerV3Entity failed with error message Request failed with status code PreconditionFailed and CDS error code : 0x80060892 response message: A record that has the attribute values Account Number, Company already exists. The entity key Account Table Key requires that this set of attributes contains unique values. Select unique values and try again public static void main(Args _args) { DirPartyCDSEntity associatedParty; CustCustomerV3Entity customer; System.Exception ex; try { ttsbegin; associatedParty.PartyType = enum2Str(DirPartyType::Organization); associatedParty.OrganizationName = 'Org1'; associatedParty.insert(); ttscommit; ttsbegin; customer.CustomerGroupId = 'CASH'; CustGroup custGroup = CustGroup::find(customer.CustomerGroupId); NumberSeq numberSeq; if(custGroup.CustAccountNumSeq) { numberSeq = NumberSeq::newGetNumFromId(CustGroup.CustAccountNumSeq); } else { numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount()); } customer.CustomerAccount = numberSeq.num(); customer.PartyNumber = associatedParty.PartyNumber; customer.PartyType = associatedParty.PartyType; customer.SalesCurrencyCode = 'GBP'; customer.SalesTaxGroup = 'STD'; customer.insert(); ttscommit; } catch(ex) { info(ex.Message); } }
public static void main(Args _args) { DirPartyCDSEntity associatedParty; CustCustomerV3Entity customer; System.Exception ex; try { ttsbegin; associatedParty.PartyType = enum2Str(DirPartyType::Organization); associatedParty.OrganizationName = 'Org1'; associatedParty.insert(); ttscommit; ttsbegin; customer.CustomerGroupId = 'CASH'; CustGroup custGroup = CustGroup::find(customer.CustomerGroupId); NumberSeq numberSeq; if(custGroup.CustAccountNumSeq) { numberSeq = NumberSeq::newGetNumFromId(CustGroup.CustAccountNumSeq); } else { numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount()); } customer.CustomerAccount = numberSeq.num(); customer.PartyNumber = associatedParty.PartyNumber; customer.PartyType = associatedParty.PartyType; customer.SalesCurrencyCode = 'GBP'; customer.SalesTaxGroup = 'STD'; customer.insert(); ttscommit; } catch(ex) { info(ex.Message); } }
Hi D365FO user,
I did not report this error with the code. As per the error, suggest you go to the database and check if these two fields have already been inserted and are they unique keys?
It seems like you have a customization for number sequences per customer group. I would suggest using the debugger to check if there is any number allocated or probably there is an overlap in the number sequences.
Hi Andrea, JudyI've noticed that this only happens if i create a party of type org. I tried a person party type and i got no errors, then when i switched back to organization i got the error i specified in the question.can you please explain more how to know if the issue is in the number sequence? what do i need to do exactly?
public static void main(Args _args) { DirPartyCDSEntity associatedParty; CustCustomerV3Entity customer; System.Exception ex; try { ttsbegin; //org //associatedParty.PartyType = enum2Str(DirPartyType::Organization); //associatedParty.OrganizationName = 'Org1'; //associatedParty.OrganizationNumOfEmployees = 10; //org //person associatedParty.PartyType = enum2Str(DirPartyType::Person); associatedParty.PersonFirstName = "testOn"; associatedParty.PersonMiddleName = " MiddleNameTest"; associatedParty.PersonLastName = "LastNameTest"; //person associatedParty.insert(); ttscommit; ttsbegin; customer.CustomerGroupId = 'CASH'; CustGroup custGroup = CustGroup::find(customer.CustomerGroupId); NumberSeq numberSeq; if(custGroup.CustAccountNumSeq) { numberSeq = NumberSeq::newGetNumFromId(CustGroup.CustAccountNumSeq); } else { numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount()); } customer.CustomerAccount = numberSeq.num(); customer.PartyNumber = associatedParty.PartyNumber; customer.PartyType = associatedParty.PartyType; customer.SalesCurrencyCode = 'GBP'; customer.SalesTaxGroup = 'STD'; customer.insert(); ttscommit; } catch(ex) { info(ex.Message); } }
Do you get a value at line 42? Doesn't it already exist in CDS?
Hi Martin,
yes i get one and no it doesn't exist in CDS. Any idea?
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 664 Most Valuable Professional
André Arnaud de Cal... 522 Super User 2025 Season 2
Sohaib Cheema 303 User Group Leader