On inserted event of table D365 x++

[DataEventHandler(tableStr(SalesQuotationTable), DataEventType::Inserted)]
    public static void SalesQuotationTable_onInserted(Common sender, DataEventArgs e)
    {
        SalesQuotationTable         salesQuotationTable = sender;
        DH_SalesQuote              SalesQuote;

        select firstonly SalesQuote
            where SalesQuote.QuotationId == salesQuotationTable.QuotationId;

        if (!SalesQuote.RecId)
        {
            SalesQuote.QuotationId  = salesQuotationTable.QuotationId;
            SalesQuote.RefRecId     = salesQuotationTable.RecId;
            SalesQuote.DocumentWorkflowState    = DH_DocumentWorkflowState::NotSubmitted;
            SalesQuote.insert();
        }
    }

Comments

Popular posts from this blog

On clicked event of form button in D365 X++

Finding unit price of item from trade agreement through code AX X++

Create Sales Line Through Code AX X++ D365 Finance & Operations