Steps to add Lightning web component to Salesforce Mobile Record Page
- Build your Lwc component with the desired functionality. For example purpose, I will use a hello world component.
-
Make your component compatible with Salesforce mobile app record pages by
adding the below code to its
meta.xml
file.
<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>55.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__RecordPage</target> <target>lightning__AppPage</target> <target>lightning__HomePage</target> </targets> <targetConfigs> <!-- Applying this config to all types of pages like record page, app page etc. --> <targetConfig targets="lightning__RecordPage,lightning__AppPage, lightning__HomePage"> <supportedFormFactors> <!-- Remove the below line if you want component to show onlyu on mobile devices. --> <supportedFormFactor type="Large" /> <supportedFormFactor type="Small" /> </supportedFormFactors> </targetConfig> </targetConfigs> </LightningComponentBundle>
- Deploy the component.
-
Edit the record page where you want to add your component.
Setup -> Object Manager -> Object -> Lightning Record Pages -> Edit the page
. For example, I will go to the Contact's Lightning Record Page. - Click edit on the record page and it will open Lightning App Builder.
-
Switch the view to
Phone
from the top left section of App builder. - Search your component in the components list. Then drag and drop it onto the mobile record page.
- Save and activate the layout.
- Now, log in to Salesforce mobile app and open the record page, you should see the component over there.
Important Notes
* If you don't see the comp*onent in the mobile app make sure that you clear the cache from the mobile app settings. See the below steps.
- Tap on your avatar from the Salesforce mobile app.
- Select
Settings
. - Select
Advanced
. - Then tap on
Clear Cached Data
.
* Note that if you add your component only on the mobile view then it won't be visible on the desktop version of your record page.
* Some of the lightning components like Lightning Datatable are not supported on mobile devices.
I hope this was helpful! Please let me know in the comments if any questions.
No comments :
Post a Comment
Hi there, comments on this site are moderated, you might need to wait until your comment is published. Spam and promotions will be deleted. Sorry for the inconvenience but we have moderated the comments for the safety of this website users. If you have any concern, or if you are not able to comment for some reason, email us at rahul@forcetrails.com