Skip to main content
Tweeted twitter.com/StackSalesforce/status/1188968710008197123
added 105 characters in body
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="comMeetingHeader">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__RecordPage</target>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
  </targets>
</LightningComponentBundle>

Thanks!

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="comMeetingHeader">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="comMeetingHeader">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__RecordPage</target>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
  </targets>
</LightningComponentBundle>

Thanks!

deleted 103 characters in body
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="bearSupervisor">fqn="comMeetingHeader">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="bearSupervisor">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="comMeetingHeader">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

deleted 6 characters in body
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is undefinedempty and so is recordId variableis undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="bearSupervisor">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is undefined and so is recordId variable. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="bearSupervisor">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

I am very new to Salesforce and I am stuck using LWC with communities. The problem is simple:
I generated my record list and when I click on the record I would like to access the selected record information on a detail page.
It works well when I hardcode the recordId but when using the @api recordId, the object I get is empty and recordId is undefined. I am trying to display it on a custom Object page.

When trying to do the same in Salesforce itself, it works as I can reference the object in the meta XML.

Here is my code: JS

import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MEETING_NAME_FIELD from '@salesforce/schema/Meeting__c.Name';

export default class ComMeetingHeader extends LightningElement {
    @api recordId;

  @wire(getRecord, { recordId: '$recordId', fields: [MEETING_NAME_FIELD] })
  record;

  get meetingData() {
    return getFieldValue(this.record.data, MEETING_NAME_FIELD);
  }
}

HTML (object record seems to exist as it goes inside the if statement)

<template>
  <h1>{meetingData}</h1>
  <lightning-card title="Wire Function" icon-name="standard:contact">
      <template if:true={record}>
          <div class="slds-m-around_medium">
            <h1>Inside record</h1>
          </div>
      </template>
      <template if:true={error}>
          <h1>Inside error</h1>
          <div>{error}></div>
      </template>
  </lightning-card>
</template>

XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="bearSupervisor">
  <apiVersion>45.0</apiVersion>
  <isExposed>true</isExposed>
  <targets>
    <target>lightningCommunity__Page</target>
    <target>lightningCommunity__Default</target>
    <target>lightning__RecordPage</target>
  </targets>
</LightningComponentBundle>

Thanks!

edited title
Link
MehdiKit
  • 133
  • 1
  • 1
  • 7
Loading
added 52 characters in body
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7
Loading
added 46 characters in body
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7
Loading
deleted 3 characters in body
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7
Loading
Source Link
MehdiKit
  • 133
  • 1
  • 1
  • 7
Loading