How do I set the Created By when I create a new record via custom button?
I have a custom button that allows users to create a new record in another module. When they do this, it says the Created By is me. I have tried sending the Created_By value in the map, but it does not seem to be working. What I am doing wrong?
mp = Map();
userResp = zoho.crm.getRecords("users",1,200,{"type":"ActiveUsers"});
users = userResp.getJSON("users");
user = users.getJSON("user");
currentUserEmail = zoho.loginuserid;
currentUserId = "";
for each user in users
{
userEmail = user.get("email");
userId = user.get("id");
if(userEmail == currentUserEmail )
{
currentUserId = userId;
}
}
mp.put("Created_By",currentUserId);
createResp = zoho.crm.createRecord("Samples1",mp);