Skip to content

Instantly share code, notes, and snippets.

@arufian
Last active February 25, 2024 22:19
Show Gist options
  • Select an option

  • Save arufian/790f5004d33081f6bd207271dab43668 to your computer and use it in GitHub Desktop.

Select an option

Save arufian/790f5004d33081f6bd207271dab43668 to your computer and use it in GitHub Desktop.

Revisions

  1. arufian revised this gist Apr 1, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions dynamicFields.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    import { LightningElement, track, wire, api } from 'lwc';

    export default class Covid19 extends LightningElement {
    export default class DynamicFields extends LightningElement {

    @api recordId;
    @track fields;
    @@ -9,7 +9,7 @@ export default class Covid19 extends LightningElement {
    record;

    connectedCallback() {
    this.fields = this.objectApiName === 'Account'? 'Account.BillingCity': 'Contact.MailingCity';
    this.fields = this.objectApiName === 'Account'? ['Account.BillingCity', 'Account.Name']: ['Contact.MailingCity', 'Contact.Name'];
    }

    renderedCallback() {
  2. arufian revised this gist Apr 1, 2020. No changes.
  3. arufian created this gist Apr 1, 2020.
    19 changes: 19 additions & 0 deletions dynamicFields.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import { LightningElement, track, wire, api } from 'lwc';

    export default class Covid19 extends LightningElement {

    @api recordId;
    @track fields;
    @api objectApiName;
    @wire(getRecord, { recordId: '$recordId', fields: '$fields' })
    record;

    connectedCallback() {
    this.fields = this.objectApiName === 'Account'? 'Account.BillingCity': 'Contact.MailingCity';
    }

    renderedCallback() {
    console.log(this.record, 'record');
    }
    }