Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Roll up field

Posted on by 826

Hi ,

I have created a roll up field  in account Entity  which Display  the sum of 2 0r more ORDERS made by the account .

and also created another Rollup field to display  the MAX PRICE (totalamount) from that order. 

Now how  to display the order Name of the MAX PRICE ..? Any suggestion are welcomed 

*This post is locked for comments

  • Suggested answer
    Vipin J Profile Picture
    Vipin J 1,583 on at
    RE: Roll up field

    Just sharing a generic way to refresh roll-up field

    Refer here - https://vjcity.blogspot.com/2020/06/generic-way-to-refresh-rollup-field-in.html

  • Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Roll up field

    Please close the thread if you got the answer.

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Roll up field

    It is not possible to do this with business rule as we have to retrieve the data from another entity.

  • RamKumarb Profile Picture
    RamKumarb 826 on at
    RE: Roll up field

    Instead of using javaScript .Is this possible using Business rule..?

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Roll up field

    Hi,

    The code will look like below.

    function retrieveOrderRecords(){
    var maxPrice=  Xrm.Page.getAttribute("attributenameMaximumPrice").getValue();
    var options = "$select=Name&$filter = MaximumPrice eq maxPrice"; //Write your own Query to get Records SDK.REST.retrieveMultipleRecords("SalesOrder", options, retrieveOrdersCallBack, errorCallBack, ordersRetrieveComplete);
    }
    function retrieveOrdersCallBack(retrievedOrders) { for (var i = 0; i < retrievedOrders.length; i++) { var orderName = retrievedContacts[i].Name;
    Xrm.Page.getAttribute("attributenameOrderName").setValue(orderName); } } function errorCallBack(error) { alert(error.message); } // This function is called after all the records have been returned function ordersRetrieveComplete() { }
  • Verified answer
    ganeshm Profile Picture
    ganeshm on at
    RE: Roll up field

    hi ram,

       try to run this code in your form onload. 

    function set() {
    var accid = Xrm.Page.data.entity.getId();

    var hvalue = 0.0;
    var value = 0.0;

    var odata = "$select=AccountId,CustomerId,Name,SalesOrderId,TotalAmount&$filter=CustomerId/Id eq (guid'"+accid+"')";
    //here using accountid i am filter the data in order , which result u 
    SDK.REST.retrieveMultipleRecords("SalesOrder", odata, function(results) {

    for (var i in results) {
    //result have the object 
    var res = results[i].TotalAmount;
    var value = parseFloat(res.Value)
    //the value return is in string format , converting to int 
    if (hvalue <= value) {
    hvalue = value
    var lpid=results[i].SalesOrderId;
    var name=results[i].Name;

    }}
    if(name==undefined)
    {}
    else{
    Xrm.Page.getAttribute("new_orderamount").setValue([{ id: lpid, name: name, entityType: "salesorder"}]);

    //this help to set the value at the lookup field 
    }
    }, errorHandler, function() {});

    function errorHandler(error) {
    writeMessage(error.message);
    }}

    before putting this program in the onload  u must add the lib file for "sdk.rest" u can find it in below link

    (msdn.microsoft.com/.../gg334427(v=crm.7).aspx

  • Verified answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Roll up field

    Hi

    Using Javascript it is possible.

  • RamKumarb Profile Picture
    RamKumarb 826 on at
    RE: Roll up field

    can u suggest a javascript sample code

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Roll up field

    Hi Ram Kumar,

    You can't create a rollup field for single line of text datatypes. It works only for whole number and decimal number data types.

    The best way is to create another field to display order name of MAX PRICE and write a JavaScript code to retrieve the order name corresponding to MAX PRICE.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans