Update a LEad Owner using Deluge

Update a LEad Owner using Deluge

Hi guys,

I am trying to use a button and subsequent script to update the lead owner to that of who presses the button.

However I am getting the following error;

  • {"code":"INVALID_DATA","details":{"api_name":"Owner"},"message":"invalid data","status":"error"}
My script is as follows;

// 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);


The data looks to be formatted correctly?