Skip to main content

Notifications

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

How to create form with salesId lookup and sales line

(0) ShareShare
ReportReport
Posted on by 97

Hi All,

I need a form with design of two grids.

In first grid (in action pane having add button).When add button clicked  i need to show the sales id as lookup from sales table. After selecting saleId from lookup,

second grid i need to show the related sales line for selected sales table. In second grid, i can edit line quantity. 

I can repeat this process again like selecting other salesid and so on..

I need to have one ok button , after clicking ok button the record needs to insert in two newly created table.

First grid record (sales ids ) in header table and second grid (sales line)  record in line table.

How to achieve this design.

Thanks in advance.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: How to create form with salesId lookup and sales line

    Do you have any special character in your number sequence, not sure but it might be related. Check this thread

    community.dynamics.com/.../insufficient-inventory-transactions-with-status-picked

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: How to create form with salesId lookup and sales line

    Hi Mohit Rampal , GirishS ,

    Thanks for sharing, I created custom tables and inserted the required header and line in my main list page form. Its working fine now.

    Now i need to post paking slip for all data in my main form.

    I have one number sequence field in header table i need to do packing slip and invoice against that number sequence.

    pastedimage1680686237481v1.png

    This is my main form.

    class ITCommercialInvoicePackingSlip
    {
        public static void main(Args _args)
        {
           
            SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
            salesFormLetter salesFormLetter;
            salesFormletterParmData salesFormLetterParmData;
    
            SalesParmTable salesParmTable;
            SalesParmLine salesParmLine;
            salesLine salesLine, salesLineUpd;
            salesParmUpdate         salesParmUpdate;
            SalesTable salestable;
            ITCommercialOverview iTCommercialOverview;  // this is header
            ITCommercialInvoiceLine iTCommercialInvoiceLine; // this is line
            CustPackingSlipJour custPackingSlipJour;
            // TransDate   PackingSlipDate = //str2Date(dataContract.parmPackinSlipDate(), 213);
            
    
            select iTCommercialOverview
                where iTCommercialOverview.CommercialInvoice == 'FFME-000029';
    
            salestable= SalesTable::find(iTCommercialOverview.salesid, true);
            
            if (iTCommercialOverview && iTCommercialOverview.Status == ITCommercialInvoiceStatus::Open)
            {
                ttsbegin;
                salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::PackingSlip, VersioningUpdateType::Initial);
    
                salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
                salesFormLetterParmData.createData(false);
                salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
    
                salesParmTable.clear();
                salesParmTable.TransDate                = iTCommercialOverview.InvoiceDate;
                salesParmTable.Ordering                 = DocumentStatus::PackingSlip;
                salesParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
                salesParmTable.salesId                  = salesTable.salesId;
    
                salesParmTable.salesName                = salesTable.salesName;
                salesParmTable.DeliveryName             = salesTable.DeliveryName;
                salesParmTable.DeliveryPostalAddress    = salesTable.DeliveryPostalAddress;
                salesParmTable.CustAccount              = salesTable.CustAccount;
                salesParmTable.CurrencyCode             = salesTable.CurrencyCode;
                salesParmTable.InvoiceAccount           = salesTable.InvoiceAccount;
                salesParmTable.ParmId                   = salesParmUpdate.ParmId;
                salesParmTable.insert();
    
                while select iTCommercialInvoiceLine where iTCommercialInvoiceLine.CommercialInvoice == iTCommercialOverview.CommercialInvoice
                {
                    salesline = SalesLine::find(iTCommercialInvoiceLine.SalesId,iTCommercialInvoiceLine.LineNum);
                    salesParmLine.InitFromsalesLine(salesLine);
                    salesParmLine.DeliverNow    = iTCommercialInvoiceLine.SalesQty;
                    salesParmLine.ParmId        = salesParmTable.ParmId;
                    salesParmLine.TableRefId    = salesParmTable.TableRefId;
                    salesParmLine.LineAmount    = iTCommercialInvoiceLine.LineAmount;
                    salesParmLine.ITNetWeight  = iTCommercialInvoiceLine.NetWeight;
                    salesParmLine.setQty(DocumentStatus::PackingSlip, false, true);
                    // salesParmLine.setLineAmount(salesLine);
                    salesParmLine.insert();
                }
    
                salesFormLetter_PackingSlip = salesFormLetter::construct(DocumentStatus::PackingSlip);
                salesFormLetter_PackingSlip.transDate(today());
                salesFormLetter_PackingSlip.proforma(false);
                salesFormLetter_PackingSlip.specQty(salesUpdate::All);
                salesFormLetter_PackingSlip.salesTable(salesTable);
                salesFormLetter_PackingSlip.parmId(salesParmTable.ParmId);
                salesFormLetter_PackingSlip.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
               
                salesFormLetter_PackingSlip.run();
                // salesFormLetter.update(salesTable,systemDateGet(),SalesUpdate::PackingSlip,AccountOrder::None,NoYes::No, NoYes::No, NoYes::No);
                if (salesFormLetter_PackingSlip.parmJournalRecord().TableId == tableNum(custPackingSlipJour))
                {
                    custPackingSlipJour = salesFormLetter_PackingSlip.parmJournalRecord();
                    info(custPackingSlipJour.PackingSlipId);
                    custPackingSlipJour.PackingSlipId = iTCommercialOverview.CommercialInvoice;
                    info(custPackingSlipJour.PackingSlipId);
                }
                ttscommit;
            }
    
    
        }
    }

    I am checking for one record, its shoing this error,

    but quantity available in inventory,

    Am i missing any reference
    Pls help me on this.

    pastedimage1680686530521v2.png

    Thanks in advance

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: How to create form with salesId lookup and sales line

    You should create two custom tables for Sales order headers and Lines. You can create form with two grids and have apply Custom form pattern. The Sales Id lookup field can be unbound form field but you need to enable multi select on it. Let us know if still any queries.

    For Invoicing those selected sales orders, check this article

    gvkkishore.wordpress.com/.../

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: How to create form with salesId lookup and sales line

    Hi PJ John paul,

    For the new form also, you need to have separate table. Either you can use regular or temp table. If you use regular table delete that data once the data is inserted into newly created header and line table. It will be easy to manipulate if you use regular table.

    Thanks,

    Girish S.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: How to create form with salesId lookup and sales line

    Hi Bharani,

    Thanks for the reply.

    Yes correct. But client need a seperate form. And the want to choose sales order and in sales line grid they can edit line quantity and they try to insert the data when clicking ok button.

    For inserting selected data we can create new header and line table.

    But i am facing difficulties for the new form.

    What data source I should keep. Because evey time they open new form for selecting sales order the form should be empty. When they click ok we need ne insert all the data present in the new form to main form.

    Thanks.

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: How to create form with salesId lookup and sales line

    So scenario is to pick multiple sales orders and do invoicing in a single instance right?

    Is it not achievable from standard? If not, I will go in this approach.

    First I will create a button in the all sales orders form which will have ability to select multiple sales orders at a time and custom class in the backend. So when you click that button, then it will directly do the invoicing for all the sales orders at a time. I think new tables and new forms are not that required here.

  • PJ JohnPaul Profile Picture
    PJ JohnPaul 97 on at
    RE: How to create form with salesId lookup and sales line

    Hi mohit

    Thanks for your reply.

    My requirment is client need to invoice multiple sales order in single time.

    For that  i need to create two forms.

    Main form - For showing all selected salesa order details. Header and line tab.

    New form - when clicking new form we should keep two grids.

    First grid - for selecting sales order

    Second grid - for showing related order lines

    In first grid action pane we have one control add. When user click add button they can choose sales order from look up.

    After selecting sales order the realated sales line data should be in second grid. By this way user can add multiple sales order.

    When click on ok button this data should inserted into main form header and line type.

    For this how many tables I need to create and what is the data source for 2nd form. What all are the objects I need to use.

    Can you give some overview.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: How to create form with salesId lookup and sales line

    Hi, Your requirement is not clear. I thought the requirement is having ability to select multiple Sales orders and update quantity in sales order lines.You lost me at newly created tables. What is the purpose of these tables? Please elaborate your requirement.

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…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans