function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Callum WhitehouseCallum Whitehouse 

Help with SOQL query needed

For communities, I'm trying to show certain elements based on their profile. To get the profile of a logged in user I was planning on using a contact ID field. Here is the code:
SELECT BiRetix_Toolkit__c, AesthetiCare_Cleansers_Toolkit__c, EDS_Toolkit__c, Endocare_CELLPRO_Toolkit__c, Endocare_Concentrates_Toolkit__c,Endocare_Growth_Factor_Facials__c, Endocare_Tensage_Toolkit__c, Endocare_C_Ferulic_Toolkit__c, ENDYMED_Toolkit__c, G_T_Peels_Toolkit__c, Heliocare_360_Toolkit__c, NeoRettin_Toolkit__c, NeoRetin_Rejuvemax_Toolkit__c, Retriderm_Toolkit__c 
FROM Contact 
WHERE Contact_ID__c 
IN (SELECT ContactId FROM User WHERE username=:UserInfo.getUsername())
However this gives an error:
The left operand field in the where expression for outer query should be an id field, cannot use: 'Contact_ID__c'

Can anyone help me resolve this issue please?
 
Best Answer chosen by Callum Whitehouse
Scott Nelson SolutionistScott Nelson Solutionist
Contact_ID__c is a custom field, ContactID is the standard Salesforce ID. Try changing WHERE Contact_ID__c to WHERE ID.

Another suggestion is to consider using sharing rules and profiles if possible. 

All Answers

Scott Nelson SolutionistScott Nelson Solutionist
Contact_ID__c is a custom field, ContactID is the standard Salesforce ID. Try changing WHERE Contact_ID__c to WHERE ID.

Another suggestion is to consider using sharing rules and profiles if possible. 
This was selected as the best answer
Callum WhitehouseCallum Whitehouse
Perfect, thanks!