I have added two new Custom tab in account page

  1. Student
  2. Parents
    ( Both are stored in Contact object mapped to Account)

On click of student tab need to display the students details in data-table, As same as On click of Parents tab need to display the Parents details in data-table.

I trying to achieve this in Single LWC page. if we get the Custom tab label name will get the record type for the contact and display the record.

My Question is onclick of Custom tab in lightning app builder,will be able to get the tab label name in LWC.

  • The custom tab you mean the custom tab in lightning app builder? Jun 16 '20 at 6:09
  • Yes Rahul, custom tab in lightning app builder Jun 16 '20 at 6:11
  • 2
    Don't use the label - it can be localized.
    – Phil W
    Jun 16 '20 at 7:41

Well afaik, you can't get the selected tab, but there is another way. You can use a design attribute here. Let's say Type, and you can use the same component in both tabs with different values to the Type design attribute.

Configure a Component for Lightning App Builder

You need to define a public attribute for that, like.

@api Type

Based on the value of Type you can do your logic.

if(this.Type === 'Student'){
     // do the logic to fetch the students data
} else if (Type === 'Parents'){
     // do the logic to fetch the parents data.

Also, you need to make this attribute available to the lightning app builder by defining the below code in lwc's meta XML file.

    <targetConfig targets="lightning__RecordPage">
        <property name="Type" type="String" datasource="Student,Parents" />

Now the Type value you can set directly from app builder. Which looks something like this.

enter image description here

  • Not getting you Rahul, can you please help me to understand on this. Jun 16 '20 at 6:37
  • @SFDC_Beginner I have updated the answer. Jun 16 '20 at 7:15
  • 1
    Thanks Rahul, For Making me to understand on this :) Jun 16 '20 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.