onContactUpdate filter by LabelKeys

I’d like to update my Google Spreadsheet when a Contact is updated with a specific label.

I’ve used the code in the example but changed the console.log to be the contactName variable rather than the whole event.
export function wixCrm_onContactUpdated ( event ) {
6 const contactId = event . metadata . entityId ;
7 const contactName = ${ event . entity . info?.name?.first } ${ event . entity . info?.name?.last };
8 console . log (‘Contact updated’, contactName );

What I’d like to do is only update the Google Sheet (which I know how to do) when the contact is updated with label “XYZ”

I just need some help extracting the labelKey out of the above.

Any help would be appreciated.

Regards,

Andrew

I figured this one out

let label = ${ event . entity . info . labelKeys [ 0 ]};

this reads the first entry in the array, which isn’t foolproof but will do the trick.

This worked better
let labelArray = ${ event . entity . info . labelKeys };
let label = labelArray . search ( /custom.label/ );