Skip to main content

Notifications

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

Cannot insert the value NULL into column

(0) ShareShare
ReportReport
Posted on by 75

I am using insert_recordset to insert data in a custom table by using following query;

insert_recordset myTable (LineAmountMST,Qty, ItemId, InventDimId, InvoiceDate
            , InventSizeId, InventColorId
            , OperatingUnitID
            , COGS
            )
        SELECT SUM(LineAmountMST), SUM(Qty), ItemId, InventDimId, InvoiceDate
            from CustInvoiceTrans
            JOIN CustInvoiceJour
            where CustInvoiceTrans.SalesId == CustInvoiceJour.SalesId
            && CustInvoiceTrans.InvoiceId == CustInvoiceJour.InvoiceId
            && CustInvoiceTrans.InvoiceDate == CustInvoiceJour.InvoiceDate
            && CustInvoiceTrans.numberSequenceGroup == CustInvoiceJour.numberSequenceGroup
            && CustInvoiceTrans.InvoiceDate >= start
            && CustInvoiceTrans.InvoiceDate <= end
            OUTER JOIN InventSizeId, InventColorId
            from InventDim
            where CustInvoiceTrans.InventDimId == InventDim.InventDimId
            OUTER JOIN OMInternalOrganization
            from RetailCustInvoiceJourTable
            group by RetailCustInvoiceJourTable.OMInternalOrganization,
            CustInvoiceTrans.ItemId, CustInvoiceTrans.inventdimid, CustInvoiceTrans.InvoiceDate
            , InventDim.InventSizeId, InventDim.InventColorId
            where CustInvoiceJour.RecId == RetailCustInvoiceJourTable.CustInvoiceJour
            OUTER JOIN InventTransOrigin
            where CustInvoiceTrans.InventTransId == InventTransOrigin.InventTransId
            OUTER JOIN sum(COGS) from KSPInventTransGrouped
            where CustInvoiceTrans.InvoiceId == KSPInventTransGrouped.InvoiceId
            && InventTransOrigin.RecId == KSPInventTransGrouped.InventTransOrigin;

but it is showing following errors;

  • [SQL ServerCannot insert the value NULL into column 'Field', table 'AxDB.dbo.MYTABLE'; column does not allow nulls. INSERT fails.
  • Object Server Azure:
  • Cannot insert multiple records in MYTABLE (MYTABLE). The SQL database has issued an error.

Any solution to resolve this issue?

  • Ashraf_ahk Profile Picture
    Ashraf_ahk 75 on at
    RE: Cannot insert the value NULL into column

    Multiple lines have no record.

  • Ashraf_ahk Profile Picture
    Ashraf_ahk 75 on at
    RE: Cannot insert the value NULL into column

    OperatingUnitId = OMInternalOrganization

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Cannot insert the value NULL into column

    You're getting values of OperatingUnitID and COGS from outer-joined data sources; I think that that one of them (or both) doesn't return any record, therefore the value is NULL. That's not a valid field value in F&O.

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Cannot insert the value NULL into column

    Hi Ashraf,

    I think you have missed to add OperatingUnitId reference in the select statement.

    Try to run the select statement separately and find which values are null.

    Thanks,

    Girish S.

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…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans