Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Custom CreateProductionOrder Form to copy the sales order Id

Posted on by 529

Hello guys,

I want to dinamically add the sales order number SalesId as the same Production number Id ProdId when creating a new production from a salesline.

I have already  check the clicked method: "salesLine.type().formProduction(element);" does not telling me too much. that goes to a framework were I dont know excacly where to look on where is writting exclacly the data from the sales into the form.

thanks a lot for your time!

pastedimage1596699334173v1.pngpastedimage1596700319342v2.png

  • CBNestor Profile Picture
    CBNestor 529 on at
    RE: Custom CreateProductionOrder Form to copy the sales order Id

    You're Genius!, Thanks it works!. The code is only needed at the end of created instead of in InitValue.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Custom CreateProductionOrder Form to copy the sales order Id

    By debugging you can find out that initValue() is called from super() call in create method of the data source.

    After the super() call there's logic to fetch prodId from number sequence. I guess it replaces your value with (empty) value from (manual) number sequence.

    So you have to move your code to the end of create method.

  • CBNestor Profile Picture
    CBNestor 529 on at
    RE: Custom CreateProductionOrder Form to copy the sales order Id

    Hi Nikolaos, thanks for replaying. I have written your code as suggested. When I make debug the ProdTable.ProdId is getting the Id properly. but is not writting it into to the form. is still empty.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Custom CreateProductionOrder Form to copy the sales order Id

    Hi CBNestor,

    The code in yellow opens a new form ProdTableCreate and waits until OK or Cancell button will be pressed. The Logic you want to apply should be added to that form as initalization for production order from source.

    If you open the form method ProdTableCreate\Data Source\ProdTable\initValue, you will find the place where initialization of ProdTable record can be applied from sales line.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Custom CreateProductionOrder Form to copy the sales order Id

    The form name is ProdTableCreate.

    You could try to add following code in the initValue method of ProdTable data source on that form:

    SalesLine salesLineLocal; // Put this in the beginning of the metod
    
    // (...)
    
    // Put this after the super() call:
    if (callerBuffer.TableId == tableNum(SalesLine))
    {
        salesLineLocal = calleBuffer;
        prodTable.ProdId = salesLineLocal.SalesId;
    }

    Not that this will not work if you ever create two production orders from the same sales order (for example from different lines), since every ProdId must be unique.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans