getcurrentitem() mthod

when i try to get date field from collection in my panel code where this field i’m not connected dirctly to it’s dataset but i connected to it by refernce in anther dataset coolection an error apear. this my code

$w.onReady( ()=> {
$w(‘#dataset1’).onReady(()=>{
var date=$w(‘#dataset1’).getCurrentItem(). barithdate ;
var options = { year: ‘numeric’, month: ‘numeric’, day: ‘numeric’ };
$w(‘#text27’).text=date.toLocaleDateString(‘ar-EG’, options);

where barithdate field in client collection and i connecte client collection to booking collection by refernce .where booking collection contain refernce field refer to client collection items .in my page i use booking (R&W)dataset onlyin my pag . this error apears

An error occurred in one of datasetReady callbacks TypeError: Cannot read property ‘toLocaleDateString’ of undefined

When working with JavaScript you will sooner rather than later get a TypeError: Cannot read property ‘name’ of undefined (or TypeError: something.name is undefined or similar). This happens when you try to access a property of a value that is undefined (or similarly for values that are null ).
(The undefined property indicates that a variable has not been assigned a value, or not declared at all.)