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

Selecting Custom field from user for comparison


We use an apex class and visualforce page for calculate which users can select which pricebooks (custom object).
Within the logic I can see that Userinfo will has been added - so this looks like it will only return pricebooks for standard license users (I think I'm correct in saying this).

What I want to do within this selection query is return the pricebooks which have the same value on User field and the same value on the current users custom field Agent.
E.g. Pricebook.User__c = User.Agent_Name__c.

Below is the current code:
if(Userinfo.getUserType() == 'Standard'){           
            priceBookList = [select Product__c,name,id, name,Description__c,Contract_Start_Date__c, Internal__c from 
            Pricebook__c where Product__c=:selectedProduct and Active__c = True];

Does anyone know how I can add this in?
Anything I seem to try doesn't work.

Thanks in advance

Best Answer chosen by RadDude89

Found the answer on another thread


String myPosition = [Select My_Position__c From User Where Id = :UserInfo.getUserId()][0].My_Position__c;

Going to mark as answer in case anyone has same issue in future