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
SkyBlue2007SkyBlue2007 

User Object Update doesn't work !.

Hi all,

 

I tried to update User  Object, but it didn't work.

Then I got an error message which is '"Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []".

 

Here is VF.

<apex:page standardController="User" extensions="userExtension2" sidebar="false">
<apex:pageMessages showDetail="true" />
 <apex:sectionHeader title="AAA" subtitle="{!$User.LastName} {!$User.FirstName}"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock title="BBB">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="save"></apex:commandButton>
                <apex:commandButton action="{!cancel}" value="cancel"></apex:commandButton>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="CCC" collapsible="false" columns="1">
                <apex:inputField value="{!User.testField1__c}"></apex:inputField>
                <apex:inputField value="{!User.testField2__c}"></apex:inputField>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Here is Controller Extensions.

public class userExtension2 {
   private final User u;

   public userExtension2(ApexPages.StandardController stdController) {
      this.u = (User)stdController.getRecord();
   }

   public PageReference save() {
      try {
         update u;
      }
      catch (DmlException e) {
      }
   }
   return null;
}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

Are you passing id in youe query srtring.

 

add id in query string like this

/aspx/YourPageName?id=userid

 

userid is the is that you want to update

All Answers

Shashikant SharmaShashikant Sharma

Are you passing id in youe query srtring.

 

add id in query string like this

/aspx/YourPageName?id=userid

 

userid is the is that you want to update

This was selected as the best answer
SkyBlue2007SkyBlue2007

Hi ,

 

Thank you for your prompt reply.

I've solved my problem.

 

Thanks,

Seiji

JoeyDJoeyD

Did you solve the problem with the solution provided, or by other means?

 

i'm having the same issue.

 

Thanks

SkyBlue2007SkyBlue2007

Hi JoeyD,

 

I solved the problem with the solution provide.

Here's a Controller before transition.

public class beforeTransitionController {
   public beforeTransitionController() {
   }

   public PageReference runUserEditPage() {
      PageReference nextPage;
      nextPage = new PageReference('/apex/UserEditPage');
      nextPage.getParameters().put('id',UserInfo.getUserId());
      nextPage.setRedirect(true);
      return nextPage;
   }
}

 

Here's a Controller after transition.

public class AfterTransitionController {
   private final User user;

   public AfterTransitionController(ApexPages.StandardController stdController) {
      user = (User)stdController.getRecord();
   }
   
   public PageReference save() {
      ・・・
   }
}

 

Thanks,

SkyBlue2007