+ Start a Discussion

remote objects

In the code below, in the initial alert, I am getting the proper initial value. Example 25.0. After I call the target.upsert and and call the second alert, I get the proper result, 26.25 for the sake of argument. However, the Target__c object isn't actually updated  on the server and I can't figure out what I am doing wrong. I tried update as well. 

What am I doing wrong I've been on this problem for 2 days now.

var CalculatePercentage =()=>{
                var gpPercentage = document.getElementById('gp-percentage');
        		var volPercentage = document.getElementById('volume-percentage');
                var ids = [];
                var target = new SObjectModel.Targets__c();
                     target.retrieve((err, results)=>{
                 			alert(`before: ${r.get('q1_target_volume__c')}`);
                			target.set('q1_target_volume__c', r.get('q1_actual_volume__c') * (1+volPercentage.value/100));
                			target.set('q2_target_volume__c', r.get('q2_actual_volume__c') * 1+ (volPercentage.value/100));
                			target.set('q3_target_volume__c', r.get('q3_actual_volume__c') * 1+ (volPercentage.value/100));
                			target.set('q4_target_volume__c', r.get('q4_actual_volume__c') * 1+ (volPercentage.value/100));
							target.set('q1_target_target__c', r.get('q1_actual_volume__c') * 1+ (gpPercentage.value/100));
                			target.set('q2_target_target__c', r.get('q2_actual_volume__c') * 1+ (gpPercentage.value/100));
                			target.set('q3_target_target__c', r.get('q3_actual_volume__c') * 1+ (gpPercentage.value/100));
                			target.set('q4_target_target__c', r.get('q4_actual_volume__c') * 1+ (gpPercentage.value/100));
                			alert(`after: ${target.get('q1_target_volume__c')}`);