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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Using Node.js and Dynamics API - Can anyone assist in helping to add line items to an already existing quote?

(0) ShareShare
ReportReport
Posted on by

// Using Node.js and Dynamics API - Can anyone assist in helping to add line items to an already existing quote?  

// My sample code below, with explanation of errors:

const uuid = require('uuid/v1'); // npm package for creating guids

let finalQuote = {};
// this is the quoteid of the quote that I want to update
finalQuote.quoteid = "5081f070-c35c-11e7-aaf7-bd237d22a9d2"; 
finalQuote.name = "UPDATED NAME";
finalQuote["customerid_account@odata.bind"] = "/accounts(475b158c-541c-e511-80d3-3863bb347ba8)";

// everything above WORKS FINE, but when I try to add quotedetails (aka quote line items), I get errors

finalQuote.quote_details = [ 
    { 
        quotedetailid: uuid(),
        // the productid that I would like to add to this quote is 06283b55-c913-e711-8118-c4346baccb84
        "productid@odata.bind": "/products(06283b55-c913-e711-8118-c4346baccb84)",
        quantity: 3,
        baseamount: 4.00,
        priceperunit: 4.00,
        extendedamount: 12.00
    }
];

/* The above sample, gives the error "Deep update of navigation properties is not allowed."  I have tried a number of alternative methods (using finalQuote["quote_details@odata.bind"], for instance), but none of them are working. So rather than listing all of them, I would like to simply ask:

1.) What is the proper way to add a line item to a quote (please provide a code example)?

2.) I need to make sure that the productid of the item added is associated with an already existing product (product '06283b55-c913-e711-8118-c4346baccb84').

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I figured out a way to do this, but I am still wondering if there is an easier, more practical method.  For now, I will be creating a separate POST request for each line item, and the line item property "quoteid@odata.bind" will associate the newly-created quotedetail with the guid of the quote assigned.  POST to orgUrl + '/api/data/v8.2/quotedetails'.  Anyway, below is the body (lineItem) of the request.

    const uuid = require('uuid/v1'); // npm package for creating guids

    let lineItem = {
       quotedetailid: uuid(),
       // this is the productid of the product you want associated with this lineItem
       "productid@odata.bind": "/products(06283b55-c913-e711-8118-c4346baccb84)",
       // unit of measurement id is required - or else you get error: The unit id is missing
       "uomid@odata.bind": "/uoms(f5765d3c-de7f-4781-b19b-189571b5115c)",
       quantity: 25,
       baseamount: 50,
       priceperunit: 50,
       description: 'Description here. blah blue blee blah',
       extendedamount: 1250,
       // this is the quoteid of the quote to attach this lineItem to
       "quoteid@odata.bind": '/quotes(5081f070-c35c-11e7-aaf7-bd237d22a9d2)',
    };

    Any and all suggestions for easier/more practical methods are greatly appreciated.  Thank you!!!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans