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
MY VF and ApexMY VF and Apex 

How to Reset password for your users while using vf and apex class to create and view users?

hi friends,

i am using visualforce page and apex class to create standard user and to view user record as well as for edit functionality...

 

i haven't used <apex:detail/> to view record of any particular user...because by using this i am going to standard look and feel...

insted of using detail i have used simple vf  and in that used outputfield to dislay users record

 

here is my code..

 

 

i want to use a command button for reset password ,i haven't written any code in method(reset) of extension ...

how method will be written in extension (say method in extesnion  is reset)

<apex:page standardController="User" tabStyle="MyAdmin__tab" extensions="StaffandUserDetailPageExtension" >  <!--  <apex:detail title="false" relatedList="false"/> -->
    <apex:form >
        <apex:pageBlock mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                   
                    <apex:commandButton action="/apex/EditStaffAndUser?id={!id}" value="Edit"/>
                    <apex:commandButton action="/apex/AdminListView?intFocus=5" value="List View"></apex:commandButton>
                <!--    <apex:commandButton action="{!resetpassword}" value="Reset Password"/> -->
                    
                 </apex:pageBlockButtons>
              
              <apex:pageBlockSection title="User Information" columns="2" collapsible="false"> 
             
           
                 <apex:outputField value="{!User.User_Types__c}"/> 
                  <apex:pageBlockSectionItem >
                         <apex:outputLabel value="Active"/>
                         <apex:outputfield value="{!User.IsActive}"/>
                  </apex:pageBlockSectionItem> 
                
                  <apex:outputField value="{!User.ProfileId}"/>
                  <apex:outputField value="{!User.FirstName}"/>
                  <apex:outputField value="{!User.Username}"/>
                  <apex:outputField value="{!User.LastName}"/>
                  <apex:outputField value="{!User.Email}"/>
                  <apex:outputField value="{!User.alias}"/>
                  <apex:outputField value="{!User.CommunityNickName}"/>
     
                  
                 
                  </apex:pageBlockSection>
        
            
           
            

          
                    
                    
            <apex:pageBlockSection >

                  
                   
                   <apex:outputField value="{!User.Phone}"/>
                   <apex:outputField value="{!User.Extension}"/>
                   <apex:outputField value="{!User.Fax}"/>
           
                   <apex:outputField value="{!User.Title}"/>
                   <apex:outputField value="{!User.CompanyName}"/>
          
                   <apex:outputField value="{!User.Department}"/>
                   

         
                   
          
                   </apex:pageBlocksection>
              
              
            
      
      
          
            <!-- 
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:outputField value="{!User.EmailEncodingKey}"/>
                   <apex:outputField value="{!User.TimeZoneSidKey}"/> 
                   <apex:outputField value="{!User.LocaleSidKey}"/>
                   <apex:outputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
             --> 
               
        
            
              </apex:pageBlock>
              </apex:form>
   
  
 
 
 


   
</apex:page>

 Thanks in advance

SachiiSachii

System.resetPassword('user_sfdcId');

System.setPassword('user_sfdcId', 'new_password');

MY VF and ApexMY VF and Apex

 I am getting this error...
Error: StaffandUserDetailPageExtension Compile Error: Method does not exist or incorrect signature: System.resetPassword(String) at line 22 column 8

 

what is user_sfdcId here??

Vijaya Kumar RegantiVijaya Kumar Reganti
Hi, 

You have to use the following syntax.


public static System.ResetPasswordResult resetPassword(ID userID, Boolean send_user_email)

thanks,
Vijay
Neel88Neel88
I am tryin to implement this and get errors. Can someone help in giving the final version of this code and simple instructions. Not very familiar with coding. Highly appreciate it