Describe the bug
We execute an INSERT script to insert multiple Bi-Directional, Substitute records into the productsubstitute table.
For Bi-Directional records, the productsubstitute table is meant to have an A -> B record and a twin/reverse B -> A record. All of the "A -> B" records are created as expected, but an inconsistent and unpredictable amount of the "B -> A" records are created.
The records that are missing the twin are in a broken state.
- Manually attempting to create the twin results in an error.
- Attempting to delete the 'orphaned' record errors out, whether deleting from SQL 4 CDS or from the Dynamics web UI of a model-driven app.
-
Exception Message: The other row for the product relationship is not available.
- Full error details: Delete-ErrorDetails.txt
The only way we were able to fix these records was to reach out to Microsoft support who were able to run a script of their own (not runnable in SQL 4 CDS) to delete the problem records.
Our workaround in this case was to manually create the needed Product Relationship records using our existing model-driven app.
To Reproduce
Query to reproduce the behavior:
INSERT INTO productsubstitute (productid, substitutedproductid, salesrelationshiptype, direction)
SELECT
ptid.productid,
p.productid,
3, -- Substitute
1 -- Bi-Directional
FROM product p
INNER JOIN cdm_company c ON p.msdyn_companyid = c.cdm_companyid
INNER JOIN msdyn_productcategory pc ON p.pre_productcategory = pc.msdyn_productcategoryid
INNER JOIN product ptid ON ptid.productnumber = 'SomeProductNumber'
WHERE
c.cdm_companycode = '1234' -- Example company code
AND pc.msdyn_code = '4444' -- Example code
AND p.productnumber <> 'SomeProductNumber' -- Avoid associating with itself.
The intention of the script is to set all of the products with the expected company and product category as substitutes for the product with SomeProductNumber.
p.pre_productcategory is a lookup column to the Product Category table.
Expected behavior
All of the records and their twins are created.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- SQL 4 CDS edition: XrmToolbox
- Results of
SELECT @@VERSION:
- First observed with SQL 4 CDS 10.1.0.0 in XrmToolbox version 1.2025.7.71 (when these versions were latest) but also reproduced with later versions
Additional context
We opened a ticket with Microsoft. They were able to delete the problem records from our environment, but declined to look into the root cause since XrmToolbox and SQL 4 CDS are third-party tools.
Sponsorship
If you find this tool useful, please consider sponsoring its development.
Describe the bug
We execute an INSERT script to insert multiple Bi-Directional, Substitute records into the
productsubstitutetable.For Bi-Directional records, the
productsubstitutetable is meant to have anA -> Brecord and a twin/reverseB -> Arecord. All of the "A -> B" records are created as expected, but an inconsistent and unpredictable amount of the "B -> A" records are created.The records that are missing the twin are in a broken state.
The only way we were able to fix these records was to reach out to Microsoft support who were able to run a script of their own (not runnable in SQL 4 CDS) to delete the problem records.
Our workaround in this case was to manually create the needed Product Relationship records using our existing model-driven app.
To Reproduce
Query to reproduce the behavior:
The intention of the script is to set all of the products with the expected company and product category as substitutes for the product with
SomeProductNumber.p.pre_productcategoryis a lookup column to theProduct Categorytable.Expected behavior
All of the records and their twins are created.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
SELECT @@VERSION:Additional context
We opened a ticket with Microsoft. They were able to delete the problem records from our environment, but declined to look into the root cause since XrmToolbox and SQL 4 CDS are third-party tools.
Sponsorship
If you find this tool useful, please consider sponsoring its development.