You need to sign in to do that
Don't have an account?
Derrick Abbey
Visualforce page to update custom field on current user record
Hello SF community,
I've created a visualforce page that I would like to display as a homepage component. I've also created two custom fields on the user object that I would like that to be able to update based on the current user. I'm using the "User" standard controller, here is a bit of my code for the input fields. Do I need a custom controller or am I missing something simple? I'm fairly new to Visualforce, so I'm still learning. Thank you for any assistance!
<apex:page standardController="User" doctype="html-5.0">
<apex:inputField value="{!User.Time_off_start_date__c }"
label="" style="width:125px" showDatePicker="false" type="date">
</apex:inputField>
<apex:inputField value="{! User.Time_off_end_date__c }"
label="" style="width:125px" showDatePicker="false" type="date">
</apex:inputField>
<apex:commandButton action="{! save }" value="Submit"/>
I've created a visualforce page that I would like to display as a homepage component. I've also created two custom fields on the user object that I would like that to be able to update based on the current user. I'm using the "User" standard controller, here is a bit of my code for the input fields. Do I need a custom controller or am I missing something simple? I'm fairly new to Visualforce, so I'm still learning. Thank you for any assistance!
<apex:page standardController="User" doctype="html-5.0">
<apex:inputField value="{!User.Time_off_start_date__c }"
label="" style="width:125px" showDatePicker="false" type="date">
</apex:inputField>
<apex:inputField value="{! User.Time_off_end_date__c }"
label="" style="width:125px" showDatePicker="false" type="date">
</apex:inputField>
<apex:commandButton action="{! save }" value="Submit"/>
This will give your VF page the context of logged in user.
I had originally tried that. I get an error that says "Could not resolve the entity from <apex:inputField> value binding '{!$User.Time_off_start_date__c}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."
You have to pass the current user id as a parameter in the page.
Or
You have to create an custom controller that will query for that record along with that field.