How to pass recordId to get current Contact record details using lightning-record-view-form & lightning-output-field elements in Lightning Web Component (LWC) | import the @api decorator to get current record of Contact from recordId uses of lightning-output-field elements in Salesforce LWC

Vijayk
4 min readNov 17, 2021

--

Hey guys, today in this post we are going to learn about How to pass Record Id to get current Contact record details using lightning-record-view-form & lightning-output-field elements in Lightning Web Component (LWC).

The component uses @api to define a public recordId property. If the component is nested in a Lightning record page, which our component is, the Lightning page sets the value of recordId.

The @wire decorator tells getRecord to get the values of the specified fields on the record with the specified $recordId. The $ means that the value is passed dynamically. When the value changes, the wire service provisions data and the component rerenders. To know more detail about Get Record Data in Salesforce LWC, Click Here.

Files we used to get current Contact record details in Salesforce LWC →

lwcRecoridConDetails.html

LWc HTML File

Template HTML file to get current Contact record details through recordId in Salesforce Lightning Web Component (LWC)

lwcRecoridConDetails.js

LWC JavaScript File

It’s hold @api decorator to get current record of Contact from recordId in Salesforce lwc.

lwcRecoridConDetails.js-meta.xml

XML Meta File

It is used to where this lightning web component file you want to display as lightning__AppPage, lightning__RecordPage, lightning__HomePage.

Final Output → To Checkout Source Link, know more..

Other related post that would you like to learn in LWC

Create Lightning Web Component HTML →

Step 1:- Create Lightning Web Component : lwcRecoridConDetails.html

SFDX:Lightning Web Component >> New >> lwcRecoridConDetails.html

lwcRecoridConDetails.html [Lightning Web Component HTML]

Create Lightning Web Component JavaScript →

Step 2:- Create Lightning Web Component : lwcRecoridConDetails.js

SFDX:Lightning Web Component >> New >> lwcRecoridConDetails.js

lwcRecoridConDetails.js [LWC JavaScript File]

Create Lightning Web Component Meta XML →

Step 3:- Create Lightning Web Component : lwcRecoridConDetails.js-meta.xml

SFDX:Lightning Web Component >> New >> lwcRecoridConDetails.js-meta.xml

lwcRecoridConDetails.js-meta.xml [LWC Meta Data XML]

Lightning Web Component Meta XML

Further post that would you like to learn in LWC Flyout is a free, simple way to earn money.

If you think you and your family members also like to earn money in additional time, then go this link. In this site, you can earn money for the lifetime at low effort. To Earn Unlimited Everyday With This Trick, Sign Up Free.. Get Started for Free

Flyout is a free, simple way to earn money by placing sponsored content on your blog

Check Out:- Earn Unlimited Everyday With This Trick:- Click Here

FAQ (Frequently Asked Questions)

Does LWC have record ID?

To get the current record ID in LWC, we just need to import the api decorator from lwc module. Then, we have to declare the property recordId with @api decorator.

What is @wire in LWC?

Components use @wire in their JavaScript class to read data from one of the wire adapters in the lightning/ui*Apimodules and also to call the apex controller server-side methods using wire services.

What is refreshApex in LWC?

To query the server for updated data and refresh the cache, import and call the refreshApex() function. Invoke refreshApex() only when necessary because it incurs a network trip to query the server. The refreshApex() function returns a Promise. When the Promise is resolved, the data in the wire is fresh.

Final Output → To Checkout Source Link, know more..

Related Topics | You May Also Like

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | The Sitemap where you can find all published post on w3web.net

Originally published at https://www.w3web.net on November 17, 2021.

--

--

Vijayk
Vijayk

Written by Vijayk

Easy to learn step-by-step online tutorial by www.w3web.net

No responses yet