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
Dhilip DussaDhilip Dussa 

Need help of Apex and Visualforce

I need Apex and Visualforce\

Create Vf page for Salesforce users.
Add additional field Password
if I click on save button user has to be created with password
Note: No need sending email to the user emailid
NanduNandu
Hi Dhilip Dussa,
try this example
https://developer.salesforce.com/forums/?id=906F00000008sZCIAY
https://developer.salesforce.com/forums/?id=906F00000008wuZIAQ

Thanks, 
Nandu
Raj VakatiRaj Vakati
try this code
 
<apex:page controller="GeneratePasswordController" >
     <apex:form>
         <apex:commandButton action="{!registerUser}" value="Save" id="save"/>

     </apex:form>
</apex:page>
 
public class GeneratePasswordController{

public string pwd{get;set;}

     public GeneratePasswordController(){
      
     }
	 
	 public void registerUser(){
		 
		 Profile pf= [Select Id from profile where Name='System Administrator']; 
        
        String orgId=UserInfo.getOrganizationId(); 
        String dateString=String.valueof(Datetime.now()).replace(' ','').replace(':','').replace('-','') ;
        Integer RandomId=Integer.valueOf(Math.rint(Math.random()*1000000)); 
        String uniqueName=orgId+dateString+RandomId; 
        User uu=new User(firstname = 'ABC', 
                         lastName = 'XYZ', 
                         email = uniqueName + '@test' + orgId + '.org', 
                         Username = uniqueName + '@test' + orgId + '.org', 
                         EmailEncodingKey = 'ISO-8859-1', 
                         Alias = uniqueName.substring(18, 23), 
                         TimeZoneSidKey = 'America/Los_Angeles', 
                         LocaleSidKey = 'en_US', 
                         LanguageLocaleKey = 'en_US', 
                         ProfileId = pf.Id
                        ); 
        
        
        insert uu;
		
		
		     Integer len = 10;
          Blob blobKey = crypto.generateAesKey(128);
          String key = EncodingUtil.convertToHex(blobKey);
         String  pwd = key.substring(0,len);
          System.debug('************ '+pwd);
		  System.setPassword(uu.Id, uu);

		  
		 
	 }
}