oracle-apexoracle-apex-18.2

Why does Oracle recommend using model.setValue() method over setRecordValue() when setting multiple values?


I am using Apex 18.2. According to Apex' JSDoc, Oracle recommends one should use model.setValue() method over setRecordValue() when setting multiple values. But unfortunately, it does not mention the reason behind that. Does anyone know what it is?


Solution

  • I admire your curiosity. It will make you a great developer. :)

    To really know the difference, I recommend learning to read the source. While difficult in the beginning, it will get easier with time and become an invaluable skill.

    The APEX team makes this quite easy. Open your developer tools and then run the page in debug mode. This will load the unminified JavaScript source files into the DOM rather than the minified versions. Go to the Sources tab and locate the relevant file (it will take time to identify the right file in the beginning, but it gets easier too). You can open the file directly (better for debugging) or go right-click it and open it in another tab (better for scanning).

    enter image description here

    Then just search the code for the function you're after and read it...

    enter image description here

    As you can see, calls to setRecordValue, make a call to getRecord before proxying to the model's setValue method anyway. This is just a code path that you can avoid if you're making multiple setRecordValue calls. It's probably a bit of a micro-optimization, but they can add up.