You need to sign in to do that
Don't have an account?
Update Failed in Custom Controller
Hi I am new to visualforce but I am trying to write a controller to access and update a few custom fields. I added these fields to the User object. I have something like this.
public class CustomController {
private User user;
public CustomController(ApexPages.StandardController stdController) {
this.user = (User)stdController.getRecord();
}
public void updateField() {
String newCustomValue =Apexpages.currentPage().getParameters().get('newCustomValue');
user.CustomValue__c = newCustomValue;
update user;
}
}
My visual force page starts like:
<apex:page showHeader="false" standardController="User" extensions="CustomController">
<apex:form >
<apex:actionFunction name="updateField" action="{!updateField}" >
<apex:param id="newCustomValue" name="newCustomValue" value=""/>
</apex:actionFunction>
</apex:form>
But when I use this I get:
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
What am I missing?
I am trying to update my custom fields and have to available in my javascript rigth away.
Take a look at apex:actionFunction docs. Are you calling the updateField Javascript method w/ a parameter? Try using assignTo?
Just put reRender for your <apex:actionFunction reRender="xyz">.
you can put dummy id in reRender, either any element having this id or not.
------- i assume that you are passing user id to action function parameter from some where else(may be java script)---------
I do not why after spring relaeas 11 it works like this way only.
I am affraid that doesn't solve my issue. After I update my user object with my chagnes I don't get my updates in my javascript {!user.CustomField__c}' Why is that?
I also tried getting my user via:
/this.user = [select Id, CustomField__c from User where Id=:UserInfo.getUserId() limit 1];
What resources can I consult for editing the User object via javascript?