Scenario: You have to get the field values from the record/form in a custom function in the client script. Getting the value directly from the scriptContext is not possible in a custom function. In these cases, we use currrentRecord module.
Solution:
function customFunction() {
let currentRec= currentRecord.get();
let fieldValue= currentRec.getValue({ fieldId: ‘custpage_field’ });
}
Here customFunction() is a custom function created inside the client script.
currentRecord.get() method gets the current record itself into the required variable.
Using this method we can get any field from the current page.
NB: The currentRecord module should be selected for this method to work.