LWC Superbadge challenge 6 - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
sandhiya sudhakarsandhiya sudhakar 

LWC Superbadge challenge 6

Hi all,
I am doing my LWC superbage and I am new to LWC. I was stuck at challenge 6. I am getting below error, Please can anyone help me on this code.
TIA
User-added image
// import BOATMC from the message channel
import { LightningElement,wire } from 'lwc';
import { subscribe, unsubscribe, MessageContext } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
import { getRecord } from 'lightning/uiRecordApi';
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];

// Declare the const LONGITUDE_FIELD for the boat's Longitude__s
// Declare the const LATITUDE_FIELD for the boat's Latitude
// Declare the const BOAT_FIELDS as a list of [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
  // private
  subscription = null;
  boatId;

  // Getter and Setter to allow for logic to run on recordId change
  // this getter must be public
  get recordId() {
    return this.boatId;
  }
  set recordId(value) {
    this.setAttribute('boatId', value);
    this.boatId = value;
  }

  //public
  error = undefined;
  mapMarkers = [];

  // Initialize messageContext for Message Service

  // Getting record's location to construct map markers using recordId
  // Wire the getRecord method using ('$boatId')
 @wire(getRecord,{
   recordId:'$recordId',
   fields:[BOAT_FIELDS]
 })
  wiredRecord({ error, data }) {
    // Error handling
    if (data) {
      this.error = undefined;
      const longitude = data.fields.Geolocation__Longitude__s.value;
      const latitude = data.fields.Geolocation__Latitude__s.value;
      this.updateMap(longitude, latitude);
    } else if (error) {
      this.error = error;
      this.boatId = undefined;
      this.mapMarkers = [];
    }
  }

  @wire(MessageContext)
    messageContext;

    // Encapsulate logic for Lightning message service subscribe and unsubsubscribe
    subscribeToMessageChannel() {
        if (!this.subscription) {
            this.subscription = subscribe(
                this.messageContext,
                BOATMC,
                (message) => this.handleMessage(message),
                { scope: APPLICATION_SCOPE }
            );
        }
    }
    unsubscribeToMessageChannel() {
      unsubscribe(this.subscription);
      this.subscription = null;
  }


  // Runs when component is connected, subscribes to BoatMC
  connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;
    }
    this.subscribeToMessageChannel();
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
  }
  disconnectedCallback() {
    this.unsubscribeToMessageChannel();
}
  // Creates the map markers array with the current boat's location for the map.
  updateMap(Longitude, Latitude) {} 

  // Getter method for displaying the map component, or a helper method.
  get showMap() {
    return this.mapMarkers.length > 0;
  }
}

 
Best Answer chosen by sandhiya sudhakar
Jithin ChandJithin Chand
Hi Sandhiya,

import {
  subscribe,
  unsubscribe,
  MessageContext,
  APPLICATION_SCOPE
} from 'lightning/messageService';

and update the method as below
connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;
    }
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
    if (!this.subscription) {
        this.subscription = subscribe(
          this.messageContext, 
          BOATMC, 
          (message) => {
            this.boatId = message.recordId;
          }, 
          { scope: APPLICATION_SCOPE });
    }
  }
 

All Answers

Jithin ChandJithin Chand
Hi Sandhiya,

import {
  subscribe,
  unsubscribe,
  MessageContext,
  APPLICATION_SCOPE
} from 'lightning/messageService';

and update the method as below
connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;
    }
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
    if (!this.subscription) {
        this.subscription = subscribe(
          this.messageContext, 
          BOATMC, 
          (message) => {
            this.boatId = message.recordId;
          }, 
          { scope: APPLICATION_SCOPE });
    }
  }
 
This was selected as the best answer
sandhiya sudhakarsandhiya sudhakar
Thanks Jithin. Passed the challenge
MT P123MT P123
Hi,
I am doing the same. but i am getting imports error.
i retrieved the code and then made the changes to js file, and my imports as mentioned below and then deloyed to org. Any idea on what might be going wrong.

import { LightningElement,api,wire } from 'lwc';
import { subscribe, unsubscribe, MessageContext,APPLICATION_SCOPE } from 'lightning/messageService';
// import BOATMC from the message channel
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
import { getRecord } from 'lightning/uiRecordApi';
// Declare the const LONGITUDE_FIELD for the boat's Longitude__s
// Declare the const LATITUDE_FIELD for the boat's Latitude
// Declare the const BOAT_FIELDS as a list of [LONGITUDE_FIELD, LATITUDE_FIELD];
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];

Thanks in advance.
sandhiya sudhakarsandhiya sudhakar
Hi,
you should implement all the requirements mentioned in boatMap Component. make sure that you implement wiring the getRecord and subscribing the messaging channel in connected Callback.

 @wire(getRecord,{
   recordId:'$boatId',
   fields:BOAT_FIELDS
 })
  wiredRecord({ error, data }) {
    if (data) {
      this.error = undefined;
      const longitude = data.fields.Geolocation__Longitude__s.value;
      const latitude = data.fields.Geolocation__Latitude__s.value;
      this.updateMap(longitude, latitude);
      
    } else if (error) {
      this.error = error;
      this.recordId = undefined;
      this.mapMarkers = [];
    }
  } 
MT P123MT P123
It worked. I just had something wrong in my wiredRecord function. Thank you.
Amanda YonceAmanda Yonce
I am getting the error: "We can't find the correct wired wiredRecord() in the component boatMap JavaScript file. Make sure it was created according to the requirements, using the correct wire adapter to get the record’s data based on recordId, using BOAT_FIELDS for the fields, retrieving the geolocation, updating the map, and handling errors using the variable error."  
Any thoughts would be greatly appreciated. 

@wire(getRecord,{
recordId: '$boatId',
fields: [BOAT_FIELDS]
})
wiredRecord({ error, data }) {
if (data) {
this.error = undefined;
const longitude = data.fields.Geolocation__Longitude__s.value;
const latitude = data.fields.Geolocation__Latitude__s.value;
this.updateMap(longitude, latitude);
} else if (error) {
this.error = error;
this.boatId = undefined;
this.mapMarkers = [];
}
}
sandhiya sudhakarsandhiya sudhakar
Hi Amanda,
Did you create Map markers array with current  boat location in the UpdateMap method?

updateMap(Longitude, Latitude) {
    this.mapMarkers = [{
      location: { Latitude, Longitude },
      title: this.name,
      description: 'Coords: ${Latitude}, ${Longitude}'
    }];
  } 
Amanda YonceAmanda Yonce
Hi Sandhiya yes I have exactly like what you have there for updateMap and I am still getting the error.  I am curious in the getRecord, can you confirm that recordId:'$boatId' is correct
 
David FoleyDavid Foley
I'm getting the dreaded "We can't find the required imports in the component boatMap JavaScript file. Make sure the component was customized according to the requirements, including the imports from Lightning Web Components."

Can anyone see what's wrong here? Copying the whole file FYI ...
 
// import BOATMC from the message channel
import { LightningElement, wire } from 'lwc';
import { APPLICATION_SCOPE, MessageContext, subscribe } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
import { getRecord } from 'lightning/uiRecordApi';
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];

export default class BoatMap extends LightningElement {
    // private
    subscription = null;
    boatId;

    // Getter and Setter to allow for logic to run on recordId change
    // this getter must be public
    get recordId() {
        return this.boatId;
    }
    set recordId(value) {
        this.setAttribute('boatId', value);
        this.boatId = value;
    }

    //public
    error = undefined;
    mapMarkers = [];

    // Initialize messageContext for Message Service
    @wire(MessageContext)
    messageContext;

    // Getting record's location to construct map markers using recordId
    @wire(getRecord, { recordId: '$boatId', fields: BOAT_FIELDS })
    wiredRecord({ error, data }) {
        if (data) {
            this.error = undefined;
            const longitude = data.fields.Geolocation__Longitude__s.value;
            const latitude = data.fields.Geolocation__Latitude__s.value;
            this.updateMap(longitude, latitude);
        } else if (error) {
            this.error = error;
            this.boatId = undefined;
            this.mapMarkers = [];
        }
    }

    connectedCallback() {
        // recordId is populated on Record Pages, and this component
        // should not update when this component is on a record page.
        if (this.subscription || this.recordId) {
            return;
        }
        // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
        this.subscription = subscribe(
            this.messageContext,
            BOATMC,
            (message) => { this.boatId = message.recordId; },
            { scope: APPLICATION_SCOPE }
        );
    }

    // Creates the map markers array with the current boat's location for the map.
    updateMap(Longitude, Latitude) {
        this.mapMarkers = [{
            location: { Latitude, Longitude },
            title: this.name,
            description: 'Coords: ${Latitude}, ${Longitude}'
        }];
    }

    // Getter method for displaying the map component, or a helper method.
    get showMap() {
        return this.mapMarkers.length > 0;
    }
}

 
sandhiya sudhakarsandhiya sudhakar
 Amanda, This is my working code..You can check with this. I dont remember which one I used to check the challenge. you can try with recordId. But my boatMap component doesn't work with recordId in wiring

import { LightningElement,api,wire } from 'lwc';
import {  APPLICATION_SCOPE,subscribe, unsubscribe, MessageContext } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
import { getRecord } from 'lightning/uiRecordApi';
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
  // private
  subscription = null;
  boatId;
  // Getter and Setter to allow for logic to run on recordId change
  // this getter must be public
  @api
  get recordId() {
    return this.boatId;
  }
  set recordId(value) {
    this.setAttribute('boatId', value);
    this.boatId = value;
  }
  //public
  error = undefined;
  mapMarkers = [];
  // Initialize messageContext for Message Service
  @wire(MessageContext)
  messageContext;
  // Getting record's location to construct map markers using recordId
  // Wire the getRecord method using ('$boatId')
 @wire(getRecord,{
   recordId:'$boatId',
   fields:BOAT_FIELDS
 })
  wiredRecord({ error, data }) {
    if (data) {
      this.error = undefined;
      const longitude = data.fields.Geolocation__Longitude__s.value;
      const latitude = data.fields.Geolocation__Latitude__s.value;
      this.updateMap(longitude, latitude);
      
    } else if (error) {
      this.error = error;
      this.recordId = undefined;
      this.mapMarkers = [];
    }
  }
 
    // Encapsulate logic for Lightning message service subscribe and unsubsubscribe
    subscribeToMessageChannel() {
        if (!this.subscription) {
            this.subscription = subscribe(
                this.messageContext,
                BOATMC,
                (message) => {
                  this.boatId = message.recordId;
                }, 
                { scope: APPLICATION_SCOPE }
            );
        }
    }
    unsubscribeToMessageChannel() {
      unsubscribe(this.subscription);
      this.subscription = null;
  }
  // Runs when component is connected, subscribes to BoatMC
  connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;
    }
    this.subscribeToMessageChannel();
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
  }
  disconnectedCallback() {
    this.unsubscribeToMessageChannel();
}
  // Creates the map markers array with the current boat's location for the map.
  updateMap(Longitude, Latitude) {
    this.mapMarkers = [{
      location: { Latitude, Longitude },
      title: this.name,
      description: 'Coords: ${Latitude}, ${Longitude}'
    }];
  } 
  // Getter method for displaying the map component, or a helper method.
  get showMap() {
    return this.mapMarkers.length > 0;
  }
}
Watson MarconatoWatson Marconato
David Foley, in your first line, import "api" too.

import { LightningElement,api,wire } from 'lwc';
David FoleyDavid Foley
Hi Watson ... yep that was it ... I needed to decorate getRecordId with @wire.
Thanks!
Samuel LimaSamuel Lima

To me works hehe

// import BOATMC from the message channel
import { LightningElement,wire,api,track } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { APPLICATION_SCOPE,subscribe,MessageContext } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
// Declare the const LONGITUDE_FIELD for the boat's Longitude__s
// Declare the const LATITUDE_FIELD for the boat's Latitude
// Declare the const BOAT_FIELDS as a list of [LONGITUDE_FIELD, LATITUDE_FIELD];
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
  // private
  subscription = null;
  boatId;
  // Getter and Setter to allow for logic to run on recordId change
  // this getter must be public
  @api get recordId() {
    return this.boatId;
  }
  set recordId(value) {
    this.setAttribute('boatId', value);
    this.boatId = value;
  }
  //public
  error = undefined;
  @track mapMarkers = [];
  // Initialize messageContext for Message Service
  @wire(MessageContext)
    messageContext;
  // Getting record's location to construct map markers using recordId
  // Wire the getRecord method using ('$boatId')
  @wire(getRecord,{recordId:'$boatId',fields:BOAT_FIELDS})
  wiredRecord({ error, data }) {
    // Error handling
    if (data) {
      this.error = undefined;
      const longitude = data.fields.Geolocation__Longitude__s.value;
      const latitude = data.fields.Geolocation__Latitude__s.value;
      this.updateMap(longitude, latitude);
    } else if (error) {
      this.error = error;
      this.boatId = undefined;
      this.mapMarkers = [];
    }
  }
  // Runs when component is connected, subscribes to BoatMC
  connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;  
    }
    
    if(!this.subscription){
      this.subscription = subscribe(
        this.messageContext,
        BOATMC,
        (message) => {this.boatId = message.recordId},
        { scope: APPLICATION_SCOPE }
      ); 
    }
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
  }
  // Creates the map markers array with the current boat's location for the map.
  updateMap(Longitude, Latitude) {
    this.mapMarkers = [{
      location : {
        latitude : Latitude,
        longitude : Longitude
      }
    }];
  }
  // Getter method for displaying the map component, or a helper method.
  get showMap() {
    return this.mapMarkers.length > 0;
  }
}

David LivitsDavid Livits
Hi All,
I took everyone's recommendations here, however, I'm still running into the below error:
Challenge Not yet complete... here's what's wrong:
We can't find the correct settings for the method connectedCallback() in the component boatMap JavaScript file. Make sure the method was created according to the requirements, using the subscribeMC() method.

Here is my code:

import { LightningElement,api,wire } from 'lwc';
import { subscribe,unsubscribe,MessageContext,APPLICATION_SCOPE } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
import { getRecord } from 'lightning/uiRecordApi';
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
  // private
  subscription = null;
  boatId;
  // Getter and Setter to allow for logic to run on recordId change
  // this getter must be public
  @api
  get recordId() {
    return this.boatId;
  }
  set recordId(value) {
    this.setAttribute('boatId', value);
    this.boatId = value;
  }
  //public
  error = undefined;
  mapMarkers = [];
  // Initialize messageContext for Message Service
  @wire(MessageContext)
  messageContext;
  // Getting record's location to construct map markers using recordId
  // Wire the getRecord method using ('$boatId')
 @wire(getRecord,{
   recordId:'$boatId',
   fields:BOAT_FIELDS
 })
  wiredRecord({ error, data }) {
    if (data) {
      this.error = undefined;
      const longitude = data.fields.Geolocation__Longitude__s.value;
      const latitude = data.fields.Geolocation__Latitude__s.value;
      this.updateMap(longitude, latitude);
      
    } else if (error) {
      this.error = error;
      this.recordId = undefined;
      this.mapMarkers = [];
    }
  }
 
    // Encapsulate logic for Lightning message service subscribe and unsubsubscribe
    subscribeToMessageChannel() {
        if (!this.subscription) {
            this.subscription = subscribe(
                this.messageContext,
                BOATMC,
                (message) => {
                  this.boatId = message.recordId;
                }, 
                { scope: APPLICATION_SCOPE }
            );
        }
    }
    unsubscribeToMessageChannel() {
      unsubscribe(this.subscription);
      this.subscription = null;
  }
  // Runs when component is connected, subscribes to BoatMC
  connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;
    }
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
    if (!this.subscription) {
      this.subscription = subscribe(
        this.messageContext, 
        BOATMC, 
        (message) => {
          this.boatId = message.recordId;
        }, 
        { scope: APPLICATION_SCOPE });
  }
  }
  disconnectedCallback() {
    this.unsubscribeToMessageChannel();
}
  // Creates the map markers array with the current boat's location for the map.
  updateMap(Longitude, Latitude) {
    this.mapMarkers = [{
      location: { Latitude, Longitude },
      title: this.name,
      description: 'Coords: ${Latitude}, ${Longitude}'
    }];
  } 
  // Getter method for displaying the map component, or a helper method.
  get showMap() {
    return this.mapMarkers.length > 0;
  }
}
Md Saeed BaigMd Saeed Baig
here is my code , everything seems to be right but still i am facing below error:-
Challenge Not yet complete... here's what's wrong:
We can't find the correct settings for the method connectedCallback() in the component boatMap JavaScript file. Make sure the method was created according to the requirements, using the subscribeMC() method.


// import BOATMC from the message channel
import { LightningElement,wire,api,track } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { APPLICATION_SCOPE,subscribe,MessageContext } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
// Declare the const LONGITUDE_FIELD for the boat's Longitude__s
// Declare the const LATITUDE_FIELD for the boat's Latitude
// Declare the const BOAT_FIELDS as a list of [LONGITUDE_FIELD, LATITUDE_FIELD];
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
// private
subscription = null;
boatId;
// Getter and Setter to allow for logic to run on recordId change
// this getter must be public
@api get recordId() {
return this.boatId;
}
set recordId(value) {
this.setAttribute('boatId', value);
this.boatId = value;
}
//public
error = undefined;
@track mapMarkers = [];
// Initialize messageContext for Message Service
@wire(MessageContext)
messageContext;
// Getting record's location to construct map markers using recordId
// Wire the getRecord method using ('$boatId')
@wire(getRecord,{recordId:'$boatId',fields:BOAT_FIELDS})
wiredRecord({ error, data }) {
// Error handling
if (data) {
this.error = undefined;
const longitude = data.fields.Geolocation__Longitude__s.value;
const latitude = data.fields.Geolocation__Latitude__s.value;
this.updateMap(longitude, latitude);
} else if (error) {
this.error = error;
this.boatId = undefined;
this.mapMarkers = [];
}
}
// Runs when component is connected, subscribes to BoatMC
connectedCallback() {
// recordId is populated on Record Pages, and this component
// should not update when this component is on a record page.
if (this.subscription || this.recordId) {
return;
}
if(!this.subscription){
this.subscription = subscribe(
this.messageContext,
BOATMC,
(message) => {this.boatId = message.recordId},
{ scope: APPLICATION_SCOPE }
);
}
// Subscribe to the message channel to retrieve the recordID and assign it to boatId.
}
// Creates the map markers array with the current boat's location for the map.
updateMap(Longitude, Latitude) {
this.mapMarkers = [{
location : {
latitude : Latitude,
longitude : Longitude
}
}];
}
// Getter method for displaying the map component, or a helper method.
get showMap() {
return this.mapMarkers.length > 0;
}
}
MT P123MT P123
Below code worked for me.....

@wire(MessageContext)
    messageContext;
    // Encapsulate logic for Lightning message service subscribe and unsubsubscribe
    subscribeToMessageChannel() {
        if (!this.subscription) {
            this.subscription = subscribe(
                this.messageContext,
                BOATMC,
                (message) => this.handleMessage(message),
                { scope: APPLICATION_SCOPE }
            );
        }
    }
    unsubscribeToMessageChannel() {
      unsubscribe(this.subscription);
      this.subscription = null;
  }

  // Runs when component is connected, subscribes to BoatMC
  connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    if (this.subscription || this.recordId) {
      return;
    }
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
    if (!this.subscription) {
        this.subscription = subscribe(
          this.messageContext, 
          BOATMC, 
          (message) => {
            this.boatId = message.recordId;
          }, 
          { scope: APPLICATION_SCOPE });
    }
  }
  disconnectedCallback() {
    this.unsubscribeToMessageChannel();
}
  // Creates the map markers array with the current boat's location for the map.
  updateMap(Longitude, Latitude) {} 
  // Getter method for displaying the map component, or a helper method.
  get showMap() {
    return this.mapMarkers.length > 0;
  }
David LivitsDavid Livits
The badge is now requiring subscribeMC() to be included in the boatMap JS file for validation. I'm unable to validate after various efforts in putting in the subscribeMC() function into the boatMap.js file
Natalia BellosiNatalia Bellosi
Hi! for the subscribeMC() error, I changed the name of the method subscribeToMessageChannel() to subscribeMC() and call it in connectedCallback () { this.subscribeMC(); ... } 
David LivitsDavid Livits
@Natalia Bellosi
That was helpful! I seem to revolving around the subscribeMC() and connectedCallback() errors. I've made updates to both, but can't seem to get past this step. Is there something glaring that I'm missing here?:

// Encapsulate logic for Lightning message service subscribe and unsubsubscribe
  subscribeMC() {
      if (!this.subscription) {
          this.subscription = subscribe(
              this.messageContext,
              BOATMC,
              (message) => this.handleMessage(message),
              { scope: APPLICATION_SCOPE }
          );
      }
  }
  unsubscribeToMessageChannel() {
    unsubscribe(this.subscription);
    this.subscription = null;
}

// Runs when component is connected, subscribes to BoatMC
connectedCallback() {
  // recordId is populated on Record Pages, and this component
  // should not update when this component is on a record page.
  if (this.subscribeMC || this.recordId) {
    return;
  }
  // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
  if (!this.subscription) {
      this.subscription = subscribeMC(
        this.messageContext, 
        BOATMC, 
        (message) => {
          this.boatId = message.recordId;
        }, 
        { scope: APPLICATION_SCOPE });
  }
}
disconnectedCallback() {
  this.unsubscribeToMessageChannel();
}
Natalia BellosiNatalia Bellosi
@David Livits
You have to invoke subscribeMC() inside the connectedCallback () {
 this.subscribeMC();
// you replaced it here and it's wrong: 
  if (this.subscribeMC || this.recordId) {
    return;
  }
// should be 

if (this.subscription || this.recordId) {
return;
}
...
David LivitsDavid Livits
@Natalia Bellosi
That did it! Also had an issue with my wire messageContext, but that was an easy fix. Appreciate the guidance again!
Md Saeed BaigMd Saeed Baig

}still getting this error

// import BOATMC from the message channel
import { LightningElement,wire,api,track } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { APPLICATION_SCOPE,subscribe,MessageContext,unsubscribe } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
// Declare the const LONGITUDE_FIELD for the boat's Longitude__s
// Declare the const LATITUDE_FIELD for the boat's Latitude
// Declare the const BOAT_FIELDS as a list of [LONGITUDE_FIELD, LATITUDE_FIELD];
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
// private
subscription = null;
boatId;
// Getter and Setter to allow for logic to run on recordId change
// this getter must be public
@api get recordId() {
return this.boatId;
}
set recordId(value) {
this.setAttribute('boatId', value);
this.boatId = value;
}
//public
error = undefined;
@track mapMarkers = [];
// Initialize messageContext for Message Service
@wire(MessageContext)
messageContext;
// Getting record's location to construct map markers using recordId
// Wire the getRecord method using ('$boatId')
@wire(getRecord,{recordId:'$boatId',fields:BOAT_FIELDS})
wiredRecord({ error, data }) {
// Error handling
if (data) {
this.error = undefined;
const longitude = data.fields.Geolocation__Longitude__s.value;
const latitude = data.fields.Geolocation__Latitude__s.value;
this.updateMap(longitude, latitude);
} else if (error) {
this.error = error;
this.boatId = undefined;
this.mapMarkers = [];
}
}
// Encapsulate logic for Lightning message service subscribe and unsubsubscribe
subscribeMC() {
if (!this.subscription) {
this.subscription = subscribe(
this.messageContext,
BOATMC,
(message) => this.handleMessage(message),
{ scope: APPLICATION_SCOPE }
);
}
}
unsubscribeToMessageChannel() {
unsubscribe(this.subscription);
this.subscription = null;
}
// Runs when component is connected, subscribes to BoatMC
connectedCallback() {
// recordId is populated on Record Pages, and this component
// should not update when this component is on a record page.
if (this.subscription || this.recordId) {
return;
}
this.subscribeMC();
// Subscribe to the message channel to retrieve the recordID and assign it to boatId.
}
disconnectedCallback() {
this.unsubscribeToMessageChannel();
}
// Creates the map markers array with the current boat's location for the map.
updateMap(Longitude, Latitude) {
this.mapMarkers = [{
location : {
latitude : Latitude,
longitude : Longitude
}
}];
}
// Getter method for displaying the map component, or a helper method.
get showMap() {
return this.mapMarkers.length > 0;
}
Natalia BellosiNatalia Bellosi
The connectedCallback method should be this
connectedCallback() {
this.subscribeMC();
if (this.subscription || this.recordId) {
return;
}
}
you are reutning the method before calling the subscribeMC(); 
Md Saeed BaigMd Saeed Baig
the error is saying that "can't find correct setting for SubscribeMC" method, and i guess calling this.subscribeMC() before return statement doesn't make any sense for return statement to be called, conditions are there for a reason
Kundan ShawKundan Shaw
Its sound silly but putting this.subscribeMC(); below the comments worked. 

Like This:

// Runs when component is connected, subscribes to BoatMC
  connectedCallback() {
    // recordId is populated on Record Pages, and this component
    // should not update when this component is on a record page.
    
    if (this.subscription || this.recordId) {
      return;
    }
    // Subscribe to the message channel to retrieve the recordID and assign it to boatId.
    this.subscribeMC();
  }
 
Md Saeed BaigMd Saeed Baig
this works for me:-

// import BOATMC from the message channel
import { LightningElement,wire,api,track } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { APPLICATION_SCOPE,subscribe,MessageContext,unsubscribe } from 'lightning/messageService';
import BOATMC from '@salesforce/messageChannel/BoatMessageChannel__c';
// Declare the const LONGITUDE_FIELD for the boat's Longitude__s
// Declare the const LATITUDE_FIELD for the boat's Latitude
// Declare the const BOAT_FIELDS as a list of [LONGITUDE_FIELD, LATITUDE_FIELD];
const LONGITUDE_FIELD = 'Boat__c.Geolocation__Longitude__s';
const LATITUDE_FIELD = 'Boat__c.Geolocation__Latitude__s';
const BOAT_FIELDS = [LONGITUDE_FIELD, LATITUDE_FIELD];
export default class BoatMap extends LightningElement {
// private
subscription = null;
boatId;
// Getter and Setter to allow for logic to run on recordId change
// this getter must be public
@api get recordId() {
return this.boatId;
}
set recordId(value) {
this.setAttribute('boatId', value);
this.boatId = value;
}
//public
error = undefined;
@track mapMarkers = [];
// Initialize messageContext for Message Service
@wire(MessageContext)
messageContext;
// Getting record's location to construct map markers using recordId
// Wire the getRecord method using ('$boatId')
@wire(getRecord,{recordId:'$boatId',fields:BOAT_FIELDS})
wiredRecord({ error, data }) {
// Error handling
if (data) {
this.error = undefined;
const longitude = data.fields.Geolocation__Longitude__s.value;
const latitude = data.fields.Geolocation__Latitude__s.value;
this.updateMap(longitude, latitude);
} else if (error) {
this.error = error;
this.boatId = undefined;
this.mapMarkers = [];
}
}
// Encapsulate logic for Lightning message service subscribe and unsubsubscribe
subscribeMC(){
if(!this.subscription){
this.subscription = subscribe(
this.messageContext,
BOATMC,
(message) => {this.boatId = message.recordId},
{ scope: APPLICATION_SCOPE }
);
}
}
unsubscribeToMessageChannel() {
unsubscribe(this.subscription);
this.subscription = null;
}
// Runs when component is connected, subscribes to BoatMC
connectedCallback() {
// recordId is populated on Record Pages, and this component
// should not update when this component is on a record page.
if (this.subscription || this.recordId) {
return;
}
this.subscribeMC();
// Subscribe to the message channel to retrieve the recordID and assign it to boatId.
}
disconnectedCallback() {
this.unsubscribeToMessageChannel();
}
// Creates the map markers array with the current boat's location for the map.
updateMap(Longitude, Latitude) {
this.mapMarkers = [{
location : {
latitude : Latitude,
longitude : Longitude
}
}];
}
// Getter method for displaying the map component, or a helper method.
get showMap() {
return this.mapMarkers.length > 0;
}
}