Snippets Collections
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lightningSharingWrapper">
    <apiVersion>46.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>SubmitterWrapperLWC</masterLabel>
    <description>This is a demo component.</description>

    <targets>
        <target>lightning__FlowScreen</target>  
        <target>lightning__RecordPage</target> 
    </targets>

    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen" category="some random category">
            <property name="ruleName" type="String" role="inputOnly" />
            <property name="recordId" type="String" role="inputOnly" />
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">     
            <objects>
                <object>Account</object> 
            </objects>
        </targetConfig>
    </targetConfigs>

</LightningComponentBundle>
import { LightningElement, wire, api } from "lwc";

//1. import the methods getRecord and getFieldValue
import { getRecord, getFieldValue } from "lightning/uiRecordApi";

//2. Import reference to the object and the fields
import NAME_FIELD from "@salesforce/schema/Account.Name";
import RATING_FIELD from "@salesforce/schema/Account.Rating";
import INDUSTRY_FIELD from "@salesforce/schema/Account.Industry";

const fields = [NAME_FIELD, RATING_FIELD, INDUSTRY_FIELD];
export default class ExploreGetRecord extends LightningElement {
  @api
  recordId;

  //3. Wire the output of the out of the box method getRecord to the property account
  @wire(getRecord, {
    recordId: "$recordId",
    fields
  })
  account;

  renderedCallback() {
    console.log(this.account.data);
  }
  
  //4. Fetch the field values from the record
  get name() {
    return getFieldValue(this.account.data, NAME_FIELD);
  }

  get rating() {
    return getFieldValue(this.account.data, RATING_FIELD);
  }

  get industry() {
    return getFieldValue(this.account.data, INDUSTRY_FIELD);
  }
}

showNotification(title, msg, variant) {
  const evt = new ShowToastEvent({
    title: title,
    message: msg,
    variant: variant
  })
  this.dispatchEvent(evt);
}

//to use it, call the method passing parameters like "this.showNotification('Title', 'Message', 'success')""
@wire(callout2Apex, {id: this.recordId})
function({ error, data }) {
  if (data) {
    this.arr = JSON.parse(data).keyFromJSON;
    this.loaded = true;
  } else if (error) {
    this.loaded = false;
  };
}
star

Sat Oct 29 2022 13:00:00 GMT+0000 (Coordinated Universal Time) https://unofficialsf.com/adding-lightning-web-components-to-flow-screens/

#lwc #flow
star

Fri Jul 01 2022 15:12:47 GMT+0000 (Coordinated Universal Time) https://blog.salesforcecasts.com/how-to-use-getrecord-in-lwc/

#javascript #lwc
star

Fri Jul 01 2022 14:41:53 GMT+0000 (Coordinated Universal Time)

#lwc
star

Mon Jun 27 2022 18:40:09 GMT+0000 (Coordinated Universal Time)

#lwc #apex

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension