Anonymize users on a group by ImportManager class
This script is for anonymizing all users of a group by Import Manager class (set user info such as user email, name, phone number, address to empty). Please input your groupResourceId.
number groupResourceId = ;
if (Group_isMemberOfGroup(User_getLoggedInUser().ResourceId, groupResourceId)) print("You are member of the group, the script cannot continue");
else{
array Headers = {"userId","PhoneType_NotIdentified","PhoneType_Home1","PhoneType_Home2","PhoneType_Mobile1","PhoneType_Mobile2","PhoneType_Business1","PhoneType_Business2","PhoneType_HomeFax","PhoneType_BusinessFax","First name","Middle name","Last name","User_Email","User_Address","User_City","User_Region","User_Zipcode"};
array importData;
array a = User_getUsersByGroupResourceId (groupResourceId);
if(a.Count == 0) print("The group has no user");
else{
array data = {0};
for(j for 0; 9)//9 user phonenumber types
data.Add("#ERASE");
for(k for 0; Headers.Count-10)
data.Add(empty);
for(i for 0; a.Count) {
array data2 = new Array(data);
data2[0] = a[i].ResourceId;
importData.Add(data2);
}
Bool advancedMode=false;
ImportManager import = new ImportManager (Headers, importData, advancedMode, groupResourceId);
string userIdColumnName = "userId";
string userNameMask = "";
bool generatePasswords = false;
bool importUserInfo = true;
bool importPhoneNumber = true;
bool importAddress = true;
bool importPoints = false;
bool importQualification = false;
number parentResourceId = 0;
Dictionary mapping = new Dictionary();
import.Language = "en-US";
import.SetUserImportOptions(userIdColumnName, userNameMask, generatePasswords, importUserInfo, importPhoneNumber, importAddress, importPoints, importQualification, parentResourceId, mapping);
import.Validate();
import.Import();
print("Done");
}
}