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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Access the cost of a Product

(0) ShareShare
ReportReport
Posted on by 2,911

Hi all,

How do I access the price of a product that shows in Amount under Price List -> Price Level Items.

I have a custom entity that links an Account to a Product. I want to show the price in this custom entity but can't work out how to access it. I have played around with Views for the entity which have many fields related to currency although they hold no values.

Using advanced find as soon as I select price lists I no longer get any results from the new entity.

So basicaly I want a field that looks up the price list and displays the price list items "amount" similar I suppose to the Opportunity - Product subgrid.

*This post is locked for comments

I have the same question (0)
  • antc Profile Picture
    2,911 on at

    Any ideas?

    Or will it have to be javascript or plugin onchange event?

  • antc Profile Picture
    2,911 on at

    Worked it out with javascript will create some prettier methods but did the job.

    if (TestPrice === undefined)

        {

       var TestPrice = {};

        }

    // Get GUID of lookup field

    var lookupObject = Xrm.Page.getAttribute("new_model");

       if (lookupObject != null)

        {

            var lookUpObjectValue = lookupObject.getValue();

                  if ((lookUpObjectValue != null))

                    {

                       var lookupid = lookUpObjectValue[0].id;

                    }

        }

    MyNamespace.Machinery_OnLoad = function ()

    {

        // Create the calling URL string

        var oDataURI = Xrm.Page.context.getClientUrl()

        + "/XRMServices/2011/OrganizationData.svc/"

        + "ProductPriceLevelSet"

        + "?$select="

        + "Amount"

        + "&$filter=ProductId/Id eq (guid'"

        + lookupid

        + "')";

        var req = new XMLHttpRequest();

       req.open("GET", encodeURI(oDataURI), true);

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.onreadystatechange = function () {

           //debugger;

           if (this.readyState == 4 /* complete */)

    {

                req.onreadystatechange = null; //avoids memory leaks

               if (this.status == 200)

    {

                    //parse the response string as a JSON object.

                    var t = JSON.parse(this.responseText).d;

                    var amount = t.results[0].Amount.Value;

                    alert(amount);

                }

               else

           {

                       alert(this.responseText);

                }

           }

       }

       req.send();

      }

  • antc Profile Picture
    2,911 on at

    I have rejected this answer and see lots of people have issues with this.

    I had used this onLoad:

    function setdefaultcurrency()

    {

       var setCurrency = new Array();

       setCurrency[0] = new Object();

       setCurrency[0].id = "08d5e90b-7b3f-e611-80e5-3863bb485428";

       setCurrency[0].name = "Australian Dollar";

       setCurrency[0].entityType = "transactioncurrency";

       Xrm.Page.getAttribute("transactioncurrencyid").setValue(setCurrency);

    }

    It does set the currency correctly but doesn't allow you to setValue of a currency (money) field. If you the reload the page it will work the second time.

    I did try to set value of the currency (money) field to "$" at same time as currency however that didn't help.

    To get round this you have to have currency set in the Options for the current user and I suspect the transactioncurrencyid field on the form.

    Is there anyway to get around this issue if user doesn't have currency set?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans