I need to get tab visibility for Permission Set. I have tabs for 2 objects:Account and Account__c. I use this SOQl request:
SELECT Id,Name,Visibility,ParentId FROM PermissionSetTabSetting WHERE (ParentId IN ('0PS5g000005r8bWGAQ')) AND (Name IN ('standard-Account','Account__c')) ORDER BY Id ASC NULLS FIRST LIMIT 2000
0PS5g000005r8bWGAQ - Permission Set Id standard-Account,Account__c - tab Names from TabDefinition.
When i use this query in anonymous, sf inspector or query editor it returns required data :
BUT !!! When i use this query in my Apex code(i hardcoded it) it returns me null.
I found out that in my transaction Name of standard tab is replaced from 'standard-Account' to 'Account'.
And Name of custom tab is replaced from 'Account__c ' to '01r5g000000EJou'. It's CustomTadDefinition id.
So If i replace my SOQl query In Apex class like that:
SELECT Id,Name,Visibility,ParentId FROM PermissionSetTabSetting WHERE (ParentId IN ('0PS5g000005r8bWGAQ')) AND (Name IN ('Account','01r5g000000EJou')) ORDER BY Id ASC NULLS FIRST LIMIT 2000
i'll get all needed info.
But to get CustomTadDefinition id , i need to use Tolling API for each custom tab.
This apex method is triggered from LWC. When i call this method from anonymous it works fine.
It's the same user, i checked it. I use without sharing classes.
I don't understand why i get different result.