I have built a custom list view that lists custom objects. The list view component allows filtering based on a field of the custom object. This all works smoothly, but I want to add a feature where the default filter view is based on the profile the user is viewing from. Currently it is default to "All".

  • What is ALL? A variable or string?
    – pk1772
    Jun 23, 2021 at 17:23
  • A constant variable. In my file I have const ALL = 'All';.
    – Lia
    Jun 23, 2021 at 17:28
  • In that case you can assign the value in connectedCallback() like this.currentFilter = this.ALL; or simply use it like @track currentFilter = 'All'; in the declaration.
    – pk1772
    Jun 23, 2021 at 17:31
  • What is connectedCallback? How can this track my userId variable and assign the correct filter option?
    – Lia
    Jun 23, 2021 at 17:33

1 Answer 1


Probably modify the code a bit like -

@track currentFilter;
@wire(getUserId, {})
getUserIdData({ error, data }) {
    if(data) {
        if (data === '00e1F000000mZ8y') { // if it is DF profile
            this.currentFilter = this.DF;
        } else if (data === '00e1F000000mZ9D') { // if it is RAC profile
            this.currentFilter = this.RAC
        } else {
            this.currentFilter = this.ALL;
    } else if (error) {
      //handle error
  • I tried this, except I had my getUserId method return a String instead (since I don't know what data type DF, RAC, and ALL would be for when specifying what kind of data type to return. I did the comparisons in your if statements in my method itself, However it looks like it still defaults to ALL :(
    – Lia
    Jun 23, 2021 at 19:51
  • Please modify your question and add the Apex logic. It defaults to ALL probably because no other conditions are matching. Also if you could shed more clarity on what you are looking for that would be helpful.
    – pk1772
    Jun 24, 2021 at 10:27
  • I modified my question with the asked information!
    – Lia
    Jun 24, 2021 at 11:36
  • I see what's wrong. UserInfo.getProfileId() would return 18 char ID and you are comparing with 15 char. So the checks are failing and it is going to else block.
    – pk1772
    Jun 24, 2021 at 12:25
  • 1
    15 digit case-sensitive version is referenced in the UI and also visible in browser 18 digit case-insensitive version which is referenced through the API
    – pk1772
    Jun 24, 2021 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .