Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Export Product Model Query from BLOB to readable format with X++/SQL

(0) ShareShare
ReportReport
Posted on by 20

Hello all

We are trying to get our configurable products exported to a 3rd party sales tool.

We know how to export a product configuration model as an xml from the UI.
The only problem is that the query which defines the fields and limitations each product has is in binary format and not readable.

Below is an SQL code to to see the query from SQL and even see some of the data it consists.
Just replace [YOUR PRODUCT MODEL RECID with the recId you get when going to the Product information management -> Common -> Product configuration models and selecting Record info with 2nd mouse button over some of the models.

-- PRODUCT MODEL

SELECT
  T5.QUERY,
  T4.EXPRESSION,
  CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), T5.QUERY)) AS TEXT
FROM
  -- T1 = PRODUCT CONFIGURATION MODEL
  PCPRODUCTCONFIGURATIONMODEL T1
JOIN
  ECORESCATEGORY T2
  ON  T1.ROOTCOMPONENTCLASS = T2.RECID
JOIN
  -- T3 = ALL CONSTRAINTS
  PCCOMPONENTCONSTRAINT T3
  ON  T2.RECID = T3.COMPONENTCLASS
JOIN
  -- T4 = CONSTRAINT
  PCCONSTRAINT T4
  ON  T3.CONSTRAINT_ = T4.RECID
LEFT JOIN
-- T5 = TABLE CONSTRAINTS
  PCTABLECONSTRAINTDEFINITION T5
  ON  T4.TABLECONSTRAINTDEFINTION = T5.RECID

WHERE
  T1.RECID = [YOUR PRODUCT MODEL RECID]

For example, the above code gives us the query like this from one of our models (exactly like the export product model saves it in the xml file):

0x07FD305F0100004A012F270000110001E649030000000A4DE90300000000840457004D00440049006E00760065006E0074005400610062006C00650045007800700061006E0064006500640031000000110001E803340057004D00440049006E00760065006E0074005400610062006C00650045007800700061006E0064006500640031005F0031000000E209300057004D00440049006E00760065006E0074005400610062006C00650045007800700061006E0064006500640031000000094DE8030000F319000000920402001100010000FFFFFFFFFFFFFFFF9B04FFFF9A04FFFF0157004D00440049006E00760065006E0074005400610062006C00650045007800700061006E00640065006400310000004900740065006D004900640000003200300034003200310034000000E803000000000000000100000000000001FFFFFFFF009005000000000000000000000000000000000000000000000000000000000000FF

In addition the code gives us the expression constraints and the query in semi readable format as TEXT field (where we can see some of the itemId's used in the range).

Is there any way to get that query shown/saved as readable xml or other structured format, or is it Ax's own binary format that cannot be exported out in any other way?

And yes, we have tried the methods presented here:
http://abraaxapta.blogspot.com/2011/06/accessing-dynamics-ax-containers-from.html?m=1
https://ashirokikh.com/converting-business-central-blob-to-text-with-sql-clr/

  • Mikko Saarinen Profile Picture
    Mikko Saarinen 20 on at
    RE: Export Product Model Query from BLOB to readable format with X++/SQL

    Thank you Martin. We will try this path.
    I had some trouble finding where the query is actually stored in AOT, so thank you for pointing that out.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 231,399 Most Valuable Professional on at
    RE: Export Product Model Query from BLOB to readable format with X++/SQL

    It's a packed Query object. I don't think you can convert in any way in SQL, but you can easily create a Query instance in X :

    Query q = new Query(pcDatabaseRelationConstraintDefinition.Query);

    Then you can utilize its methods for exporting to a SQL-like string or to XML, if the output meets your needs. Or you can write your own conversion.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

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,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans