# Bulk User creation Script?

**URL:** <https://discourse.farcrycore.org/t/bulk-user-creation-script/1635>\
**Category:** support\
**Created:** [April 29, 2019, 11:22pm UTC](https://discourse.farcrycore.org/t/bulk-user-creation-script/1635 "2019-04-29T23:22:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillipjrasmuss](https://discourse.farcrycore.org/user_avatar/discourse.farcrycore.org/phillipjrasmuss/32/1233_2.png) [@phillipjrasmuss](https://discourse.farcrycore.org/u/phillipjrasmuss)\
**Post date:** [April 29, 2019, 11:22pm UTC](https://discourse.farcrycore.org/t/bulk-user-creation-script/1635/1 "2019-04-29T23:22:15Z")

</div>

Has anyone here already created a script for entering in bulk users from a speadsheet or db?

Cheers  
Phil

---

<div class="post-metadata">

**Author:** ![phillipjrasmuss](https://discourse.farcrycore.org/user_avatar/discourse.farcrycore.org/phillipjrasmuss/32/1233_2.png) [@phillipjrasmuss](https://discourse.farcrycore.org/u/phillipjrasmuss)\
**Post date:** [May 1, 2019, 1:34am UTC](https://discourse.farcrycore.org/t/bulk-user-creation-script/1635/2 "2019-05-01T01:34:06Z")

</div>

Found this [Redirecting to Google Groups](https://groups.google.com/forum/#!searchin/farcry-dev/user$20import%7Csort:date/farcry-dev/xtdi6zIxu3Y/oPxOjZn7R7QJ)  
Will update on how I go 🙂

---

<div class="post-metadata">

**Author:** ![phillipjrasmuss](https://discourse.farcrycore.org/user_avatar/discourse.farcrycore.org/phillipjrasmuss/32/1233_2.png) [@phillipjrasmuss](https://discourse.farcrycore.org/u/phillipjrasmuss)\
**Post date:** [May 1, 2019, 4:38am UTC](https://discourse.farcrycore.org/t/bulk-user-creation-script/1635/3 "2019-05-01T04:38:51Z")

</div>

Ok well the above wasn’t much help, but I managed to Frankenstein some existing code I’ve used in the past while looking at the editCLIENTUDUser.cfm for inspiration.  
The below function only requires a struct containing {firstname,lastname,username,password}

```
function createUser(struct stNewUser){
    var oUser = createobject("component","#application.packagepath#.types.farUser");
    var oProfile = createobject("component","#application.packagepath#.types.dmProfile");
    var stUser = {};
    var stProfile = {};
// create struct for farUser
stUser.locked = 0;
stUser.lockedBy = '';stUser.objectID = createUUID();
stUser.datetimeCreated = now();
stUser.lastUpdatedBy = 'farcry_CLIENTUD';
stUser.datetimeLastUpdated = now();
stUser.createdBy = 'farcry_CLIENTUD';
stUser.ownedby = ''; 
stUser.typeName = 'farUser';    	
stUser.userid = stNewUser.username;
stUser.password = stNewUser.password;
stUser.userstatus = "active";
stUser.aGroups = ['E689D131-A4A0-21F0-45AB44EC3AB144CD'];// Member objectid in my table

oUser.setData(stProperties=stUser,user='admin');
// get the newly created user so we can attach a profile to it
stUser = oUser.getData(objectid=stUser.objectID);

// create struct for dmProfile
stProfile.locked = 0;
stProfile.lockedBy = '';

stProfile.objectID = createUUID();
stProfile.datetimeCreated = now();
stProfile.lastUpdatedBy = 'farcry_CLIENTUD';
stProfile.datetimeLastUpdated = now();
stProfile.createdBy = 'farcry_CLIENTUD';
stProfile.ownedby = '';

stProfile.typeName = 'dmProfile';
stProfile.firstname = stNewUser.firstname;
stProfile.lastname = stNewUser.lastname;
stProfile.label = stProfile.firstname & ' ' & stProfile.lastname;
stProfile.BRECEIVEEMAIL = 0;
stProfile.username = "#stUser.userid#_CLIENTUD";
stProfile.userdirectory = "CLIENTUD";

oProfile.setData(stProperties=stProfile,user='admin');

}// end function
```
