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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create SalesOrderDetail in Plugin No Populate Amount

(0) ShareShare
ReportReport
Posted on by 40

Hi Guys,

If anyone can help me with this, really appreciatte, i write a plugin that create a Sales Order Detail for Order, but whn i created the amount not bring back automatically from Price list, buen when i added manually it does, my code:

  var orderProduct = new Entity
                    {
                        LogicalName = "salesorderdetail"
                    };

                    orderProduct.Attributes.Add("salesorderid", new EntityReference("salesorder", id_pedido));
                    orderProduct.Attributes.Add("productid", new EntityReference(producto.LogicalName, producto.Id));
                    orderProduct.Attributes.Add("quantity", Convert.ToDecimal(1));
                    orderProduct.Attributes.Add("uomid", new EntityReference("uom", producto.GetAttributeValue<EntityReference>("defaultuomid").Id));
                    service.Create(orderProduct);


05_2D00_Oct_2D00_16-00_2D00_41_2D00_46.png

And no calculate amount and totals, but the product is in the PreceList with amount.

Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi Jose,

    Add below line in your code to Set Pricing field as Use Default on order detail record.

    orderProduct.Attributes.Add("ispriceoverridden",false);

    This should resolve your problem.

    Kindly tick verify answer if this resolves your query.

  • Jose Abad Profile Picture
    40 on at

    hi Yadnyesh,

    Thank you for you response, No the change that you me suggested, not work. my code is:

      var orderProduct = new Entity
                        {
                            LogicalName = "salesorderdetail"
                        };
    
                        orderProduct.Attributes.Add("salesorderid", new EntityReference("salesorder", id_pedido));
                        orderProduct.Attributes.Add("productid", new EntityReference(producto.LogicalName, producto.Id));
                        orderProduct.Attributes.Add("quantity", Convert.ToDecimal(1));
                        orderProduct.Attributes.Add("uomid", new EntityReference("uom", producto.GetAttributeValue<EntityReference>("defaultuomid").Id));
                        orderProduct.Attributes.Add("ispriceoverridden", false);
    
                        service.Create(orderProduct);

    7723.05_2D00_Oct_2D00_16-00_2D00_41_2D00_46.png

    The result is the same thing. the amount of product not automatically load.

  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Can you check below setting on your environment?

    Go to Settings > Administration > System Settings.

    Go to Sales Tab and check value of 'Set Pricing Calculation preference'. It should be yes in your case.

  • Jose Abad Profile Picture
    40 on at

    Thans fro response, Yad

    Yes, it does, the setting are ok:

    05_2D00_Oct_2D00_16-07_2D00_21_2D00_58_2D002D00_ventas.png

    But are face still the same problem..

  • Verified answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Thanks for the Screenshot. Can you also provide screenshot of the price list item you are selecting in order detail and screenshot of the order detail record created through code?

    Also, can you check if 'Select Product (isproductoverridden)' is set to Existing on order detail record. Try adding below line in the code.

    orderProduct.Attributes.Add("isproductoverridden", 0);

  • Jose Abad Profile Picture
    40 on at

    Yes, Yad, sure, let me screen the images:

    price list element:

    2_2D00_sale.png

    Product order detail:

    2_2D00_sale.png

    Let me test the code setting in '0' of isproductoverridden for this, and i comment you.

  • Jose Abad Profile Picture
    40 on at

    Yad,

    No, the code orderProduct.Attributes.Add("isproductoverridden", 0); doesnt work, because its accept only Bool values.

  • Jose Abad Profile Picture
    40 on at

    Yad,

    I think i found the problem:

    • The Order, that is created by Workflow its state code is blocked or something, an then yo can add product but no has recalculation and other details.

    I dont know why the order created "sent" read only, but i test with another Order Open, and the code was right! 

    If you can tell me how change this "state code" in workflow or moment that happen would be apprecite.

    Thnks!!

  • Yadnyesh Kuvalekar Profile Picture
    4,102 on at

    Hi Jose,

    I didn't get it. Can you please help me with an example and also the workflow screenshots?

  • Suggested answer
    Jose Abad Profile Picture
    40 on at

    Hi Yadnyesh,

    My solution was, add the products and later update the record de sales order, and thats it, its work!!   thanks for your support

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans