web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to get a reference from sales order to production

(0) ShareShare
ReportReport
Posted on by 174

I'm trying to find a reference point for a sale order to pin it with a production order but I can't find any possible columns for it.

My task is to get all ProdID that are created from a sale order. I'm working on SalesTable form.

I have the same question (0)
  • Crispin John Augustine Profile Picture
    37,081 on at

    If you look at the relations in ProdTable, you will find the correct columns for joining with SalesTable and SalesLine..

  • RadekM Profile Picture
    174 on at

    Look like in Salesline retaion is ProdTableRef class reference. But how can I get into this data with a relation ?

  • Crispin John Augustine Profile Picture
    37,081 on at

    Not sure, what you saw, but this is how the relation works.

    salesprodrel.jpg

  • RadekM Profile Picture
    174 on at

    Did look from salesline > Relations > prodtableref > inventrefid , inventreftype

    in AOT I got ProdTable > Relations > SalesOrderLine and the relations above you pasted.

    How can use it in select statement ?

    Could you give me a example for it?

    I need something like this. Select prodid, collectrefprodid from prodtable where inventrefid == current.salesid ??

  • Crispin John Augustine Profile Picture
    37,081 on at

    You already have the tables and relations now.

    As to writing a select statement, you have to go through docs.microsoft.com/.../xpp-data-query

  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    Whatever fields present  in the  relation , you can use those in where clause while building your query.

  • RadekM Profile Picture
    174 on at

    Can someone say me why I get '.' expected error at the end in this ?

    I need to get all prodid from collectref since the nested statement gives me just the main prodid and collectref

    select ProdId, ProdStatus from prodtable where prodtable.CollectRefProdId in (select  ProdId, CollectRefProdId, ProdStatus from prodtable join salestable where prodtable.InventRefId == salestable.salesid);
                    Info(strFmt('%1,%2, %3', prodtable.ProdId, prodtable.CollectRefProdId, prodtable.ProdStatus));

  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi RadekM,

    The select syntax is incorrect. Subqueries are not supported in x++.

    In your case use join between all tables.

  • RadekM Profile Picture
    174 on at

    I dont see how should it work for me. From my first select I got exact that what wanted but now I need to use this value in another select .

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi RadekM,

    You just need to replace "in" with "join". And don't forget to declare all variables.

    select prodtable 
    exists join prodtable1
    	where prodtable1.ProdId = prodtable.CollectRefProdId
    exists join salestable 
    	where prodtable1.InventRefId == salestable.salesid

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans