Anonymize all users that are child of given resource by ImportManager class
This script using ImportManager class for anonymizing all users that are child of the given resource, also include user on sub children (set user info such as user email, name, phone number, address to empty).
Please input resoureIDToLookUnder for running
array a = Resource_searchByName("", 1, 0, NAME_SEARCH_TYPE_START, 0, resoureIDToLookUnder, true);
if(a.Count ==0) {
print("There is no user under the resource");
return;
}
number loggedInUser = User_getLoggedInUser().ResourceId;
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 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){
if(loggedInUser == a[i][RESOURCE_RESOURCE_ID]){
print("You are child of the resource, the script cannot continue");
return;
}
array data2 = new Array(data);
data2[0] = User_getUserByResourceId(a[i][RESOURCE_RESOURCE_ID]).PrimaryKey;
importData.Add(data2);
}
number groupResourceId = 0;
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");