Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Product Cost Price Field in Opportunity Product

Posted on by Microsoft Employee

Dear Support,

Is it possible to populate Standard Cost price field value to custom field in Opportunity Product?

We have a requirement of having Cost Price of the Opportunity Product, and we have created custom field in Opportunity product, however we are having difficulty getting the Product's Standard cost price to Opportunity Product. We have tried Workflow and we are not able to get the cost price via workflow.

We have read the following,  however not sure this will work in Dynamics CRM 2015 On-Premises

https://community.dynamics.com/crm/f/117/t/148584

Is it possible to help us with JavaScript or any other way to achieve this?

Thanks

Satheesh Balasegaram

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Product Cost Price Field in Opportunity Product

    Hi John,

    Thanks for your answer.

    in this question Drew helped me to get the Standard Cost price from Product Catalog.

    However, our requirement is to calculate the total cost of each Opportunity Product and calculate the profit margin in Opportunity Level.

    I am having difficulty with Cost price field ( new custom field created) in opportunity product form to rollup in Opportunity level, but this new field is calculated field.

    Therefore, I would like to use java script to retrieve the standard Cost Price. But my question is will Java script work when users adding the existing product using + sign? End user will not open Opportunity product form.

    Thanks

    Satheesh Balasegaram

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Drew,

    This is because of currency exchange. our base currency is USD and we are using AED.

    i am trying to find out any solutions. if you come across any please let us know.

    Thanks

    Satheesh

  • Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Satheesh,

    Weird.  You are not doing any calculations on the field (multiplication) that could cause a rounding issue (www.powerobjects.com/.../rounding_numbers-in-microsoft-dynamics-crm)?

    If no calculations then this looks like a bug to me and I was not aware of this.

    Thanks,

    Drew

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Drew,

    That's right, i have noted that down during my test. I will try that with workflow. However i have another issue with decimals in same calculated field

    Product - Standard Cost = 1240.00

    In Opportunity product - in Calculated field it show as 1240.01

    i am experiencing this in all currency calculated fields. Any Solution?

    We are in Dynamics CRM 2015 On-Premises.

    Thanks

    Satheesh B

  • Suggested answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Satheesh,

    So I was thinking about this approach as I was driving home today...  One challenge I see here, which might be an issue depending on your business case.  If the product's cost changes next year then it will reflect the new cost on the opportunity product because it is a calculated field.  I would expect this is not what you would want.  To address this problem I would suggest the following approach.  You can utilize the standard cost field that comes from the calculated field for the opportunity product until the opportunity is closed and on close then run a workflow that will copy that cost to an "actual cost field" which would be be fixed from that point forward for analysis.  

    Not sure if this is an issue for you but thought I would mention.

    Thanks,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Drew,

    I have tried and new calculated field is getting updated with Products's Standard Price.

    Let me test this in Production and will verify at the earliest.

    Thanks

    Satheesh

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    Yadnyesh Kuvalekar 4,102 on at
    RE: Product Cost Price Field in Opportunity Product

    Hi, You can try the approach suggested by Drew i.e. creating calculated field. But in that case, calculated field will be read only field. If you want to change it later, you can use JavaScript as explained in below blog:

    themscrmexpert.wordpress.com/.../get-lookup-fields-data-on-child-form-using-javascript-without-querying-the-record

  • Verified answer
    Drew Poggemann Profile Picture
    Drew Poggemann 9,079 on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Satheesh,

    Maybe I am not completely understanding what you are doing but I created a calculated field on the opportunity product called "Cost" and set this to the productid.new_standardcost in the action of the calculated field.  This set the value correctly on the opportunity product to the "new_standardcost" in my case from the product.

    Hopefully this is what you were looking to do.

    Thanks

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Satheesh,

    If you set the pricing field on the opportunity product to 'Override Price', you can then update the cost price to what ever you need it to be.

    However I assume the reason you have created a custom price field is because you did not want to use price lists? For a more correct solution I would recommend you create a default price list and update the pricing back to the price list based on your custom cost calculation. This will need to be done using a plugin.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Product Cost Price Field in Opportunity Product

    Hi Satheesh,

        You could use Javascript to retrieve the StandardCost from the Product that is associated with the Opportunity Product, and then set your custom field with that retrieved value. You would use the SetValue method to set the custom field in Javascript, like so:

    Xrm.Page.getAttribute("cncy_revenue").setValue(<yourStdCostValue>);

    Hope that helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans