Update Text Field with Owner Id form a Record

Update Text Field with Owner Id form a Record

I would like to obtain the number of UserId from the record owner into a text field with "OwnerId2" API name



I'm trying with the following function. But can't get it work. 

// Fetch the main record from the custom module
ActivityRecord = zoho.crm.getRecordById("Activities1",Activityid);

// Get the "OwnerId" lookup field from the main record
ownerIdDetails = ActivityRecord.get("idowner");

// Extract the ID from the "OwnerId" lookup field
actualOwnerId = ownerIdDetails.get("id");

// Prepare a map to update the record
updateMap = Map();
updateMap.put("OwnerId2",actualOwnerId);

// Update the "OwnerId2" field in the custom module
updateResponse = zoho.crm.updateRecord("Activities1",Activityid,updateMap);

// Log the update response for debugging
info updateResponse;