Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Update record REST JavaScript not working for money field

$
0
0

I have a lookup on a form where a user will select a Weekly Budget record.  Once they select the record, it pulls the budget amount from the selected record and populates it to a field called Budget Amount on the form.  I perform calculations (subtraction) on this form and then update the Budget Amount field with the new weekly budget value.  My problem is that I am not able to successfully take that Budget Amount value and update it back to the original Weekly Budget record.  My code runs alright, but the value is still the same.  I tried looking for an example, but all the SDK examples show just setting a given value instead of setting it to a field's value.

Here is my code

 //  Update Weekly Budget value back to Weekly Budget record
 function updateWeeklyBudgetDetails(weeklybudgetId) {
     // Declare variables
     var budget = {};
     var weeklyBudget = Xrm.Page.getAttribute("new_budgetamount").getValue();
     var finalPledgeAmount = Xrm.Page.getAttribute("new_pledgeamt").getValue();
     var updatedWeeklyBudget;

     // Subtract Final Pledge Amount for this Procedure and Set Updated Weekly Budget to that value
     updatedWeeklyBudget = weeklyBudget - finalPledgeAmount;
     Xrm.Page.getAttribute("new_budgetamount").setValue(updatedWeeklyBudget);

     budget.new_Amount = { Value: updatedWeeklyBudget }; // Set new Budget Amount; Budget Amount - Final Pledge Amount

     SDK.REST.updateRecord(
     weeklybudgetId,
     budget,
     "new_weeklybudget",
     function () {
         alert("The Weekly Budget record changes were saved");
     },
     errorHandler
   );
 }

Any help is appreciated!


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>