cancel
Showing results for 
Search instead for 
Did you mean: 

How to update email ids of users automatically

samnaction
Champ in-the-making
Champ in-the-making
I am creating user using Windows Active directory. The user is able to login without any problem. However he needs to update the email buy himself. Is there any way to automatically update the users email id from a text file or xls file based on his user name?
7 REPLIES 7

sanket
Champ on-the-rise
Champ on-the-rise
You can write a schedular that runs periodically (calling your java code) to update the users email id from text, csv or xls file.
http://wiki.alfresco.com/wiki/Scheduled_Actions

samnaction
Champ in-the-making
Champ in-the-making
I have zero knowledge on java script

samnaction
Champ in-the-making
Champ in-the-making
I was able to do for individual user using this script

var gens = search.luceneSearch("TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"");
var index;
for(index=0;index<gens.length;++index)
{
   if(gens[index].properties["cm:userName"]=="nazeers")
   {
      gens[index].properties["email"]="sameer@gmail.com";
      gens[index].save();
   }
}


But how to do for all users ??

Hi,

Upload file contains usernames and email id with some name for example: usesMailIds.csv
file contains username and mailId with comma separate in each line, example:
user1,user1@abc.com
user2,user2@abc.com
user3,user3@abc.com

Then in Javascript search for that file, then read content line by line and update the usermail as you are doing for single user.

samnaction
Champ in-the-making
Champ in-the-making
var a = new XMLHttpRequest(); I am getting error that XMLHttpRequest is not defined. How to read the file in javascrupt


var doc = search.luceneSearch('@cm\\:name:"usersMails.csv"')[0];
var docText = doc.content;
var lines = docText.split("\n");
for(var i=0; i<lines.length; i++){
  var userMailId = lines[i].split(",");
  var userName = userMailId[0];
  var mailId = userMailId[1];
  var user = people.getPerson(userName);
  user.properties["email"]=mailId;
  user.save();
}

samnaction
Champ in-the-making
Champ in-the-making
Thanks that did the work