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
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
Please close the thread if you got the answer.
It is not possible to do this with business rule as we have to retrieve the data from another entity.
Instead of using javaScript .Is this possible using Business rule..?
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() { }
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
Hi
Using Javascript it is possible.
can u suggest a javascript sample code
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156