You need to sign in to do that
Don't have an account?
Our Man In Bananas
VF Page lookup field in User object
Hi,
I am building a VF page for my custom object Change Request.
In my object trigger on Save, I populate the Manager field of the record with this code:
So now I am building a VF page I need to do something similar but in my extension class as currently it just shows the manager ID like this "Manager: 009w0000003LRsuAAZ".
So at the top of my VF page I have:
so what is the correct way to do this, and where am I going wrong?
I am building a VF page for my custom object Change Request.
In my object trigger on Save, I populate the Manager field of the record with this code:
if (trigger.isBefore && (trigger.isInsert || trigger.isUpdate)) { system.debug('step 3 - set Manager ID & department name'); for (Request_for_System_Change__c r : Trigger.new) { string LineManagerid = [SELECT Id, ManagerId from User where Id =: r.OwnerId].ManagerId; string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department; r.Manager__c = LineManagerId; r.Department_Name_String__c = DeptName; } }an that works fine.
So now I am building a VF page I need to do something similar but in my extension class as currently it just shows the manager ID like this "Manager: 009w0000003LRsuAAZ".
So at the top of my VF page I have:
<apex:page id="ChangeRequest" StandardController="Request_for_System_Change__c" extensions="RequestForSystemChangeController" standardStylesheets="false" showHeader="false" >and the field is defined like this:
<apex:pageBlockSectionItem> <apex:outputLabel value="Manager: "/> <apex:panelGrid columns="1"> <apex:outputText value="{!get_Manager(Request_for_System_Change__c.Owner__c)}"/> </apex:panelGrid> </apex:pageBlockSectionItem>In my extension class I have this method to get the Manager from the User object:
public string get_Manager(string owner_id){ string LineManagerid = [SELECT Id, ManagerId from User where Id =: owner_id].ManagerId; // string LineManagerid; // = [SELECT Id, ManagerId from User where Id =:ApexPages.currentPage().getParameters().get(‘Manager_id’)]; string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department; return LineManagerId; //r.Department_Name_String__c = DeptName; }But I am getting an error: Unknown function get_Manager. Check spelling.
so what is the correct way to do this, and where am I going wrong?
Hope this works as you needed.
it's on the line
Request_for_System_Change__c reqChange = [select Id, Owner__c from Request_for_System_Change__c where Id = :stdController.getId()];
it's kind of strange as the ID of the record definitely exists
Let me know if you still have problems.