You need to sign in to do that
Don't have an account?
Kevlangdo
remote object
I am trying for two days to update (upsert) records (over a 1000) from a table to a custom object. From the code below, the first alert correctly shows the initial value and after upsert, the second alert shows the correct updated value but if I physically check the data in the custom object through a standard SOQL query or through a view, the data hasn't changed.
target.retrieve((err, results)=>{ results.forEach((r)=>{ 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)); target.upsert(); alert(`after: ${target.get('q1_target_volume__c')}`); }); });
All Answers
You see, Remote Object go async, so once it's fired, you get no feedback. If on your database layer you had any data validation rules, or triggers/events firing - that then fail.. your records will not be updated.
Perhaps the "q1_target_volume__c" object has a required field that isn't being set? Or there is a trigger that tries to divide some number by "q1_target_volume__c" - and you are setting a zero into one of those fields (thus throwing a maths exception).... anything like that will cause the transaction to fail and the records not update.
You will have to use the Salesforce logs to try to trace any triggers on q1_target_volume__c, and manually check the validation rules etc. to make sure the data you are loading is valid.
That's where I'd start with this anyway! Hope that helps.
Could you try leveraging the callback function parameter in the upsert call to debug?
Something like:
VFMetadataSender.js:64 Uncaught TypeError: Cannot read property 'generateUrl' of undefined
at Object.createAppDomainFrame (VFMetadataSender.js:64)
at Object.sendViewstate (VFMetadataSender.js:66)
at SalesTargetPlanner?core.apexpages.request.devconsole=1:1050