// Get Current Loggedin user details, This gives email and Full name
loginuserid = zoho.loginuserid;
loginuser = zoho.loginuser;
// Find the current user login ID string
//This gets all user records
userresponse = zoho.crm.getRecords("users");
//This gets the users section from the list
userresponse = userresponse.getJson("users");
//This converts it to a Json List
usersjson = userresponse.toJsonList();
//Now we cycle through the outputted list, match the Fullname of the logged in user and extract the ID
for each userlisted in usersjson
{
if ( userlisted.get("full_name") == zoho.loginuser)
{
userid = userlisted.get("id");
}
}
//Create a list within a list as the Owner Field is a nested list itself
Leadowner = Map();
Owner = Map();
Owner.put("name",loginuser);
Owner.put("id",userid);
Owner.put("email",loginuserid);
Leadowner.put("Owner",Owner);
// Update the lead record witht he new owner
response = zoho.crm.updateRecord("Leads", Leadid, Leadowner);