Feb 192013
 

function changePassword(){

//Gather Employee Information from Case
var empId = nlapiGetFieldValue(‘company’);
var empName = nlapiGetFieldText(‘company’);
var itUser = nlapiGetUser();

//Set Case Field Values
nlapiSetFieldValue(‘assigned’,itUser);
nlapiSetFieldValue(‘status’,8);
nlapiSetFieldValue(‘insertsolution’,14);

//Reset User password
empPass(empId);

//Compile Outgoing Email
var itUserName = nlapiGetFieldText(‘assigned’);
var outgoingmessage = empName + ‘,

Your password has been reset to 1234user.’ + ‘

Thanks,
’ + itUserName;

//Set Compiled Email to Send to Employee
nlapiSetFieldValue(‘outgoingmessage’,outgoingmessage);

}

function empPass(empId){

//Load Employee Record and set New Passwords
var recEmp = nlapiLoadRecord(‘employee’,empId,null);
var password = ’1234user’;
var password2 = ’1234user’;

//Change Old Passwords to New Passwords
recEmp.setFieldValue(‘password’,password);
recEmp.setFieldValue(‘password2′,password2);
var empId = nlapiSubmitRecord(recEmp);

return empId;
}

via Automation: Making User Management Easy – Spearheadchange.com.