How to set related lookup field from Deluge function when creating a task

How to set related lookup field from Deluge function when creating a task

Hi, I've checked numerous posts on this topic but it seems I am missing something here. I'm trying to create a Zoho CRM task from within a function. Here's the relevant code:


//

// Get Departure and related Participant records

//

relParticipants = zoho.crm.getRelatedRecords("Passengers","Departures",DepartureID);

Dpt = zoho.crm.getRecordById("Departures",DepartureID);

//

// --> I've deleted some logic here because it's not relevant to my problem

//

task = Map();

task.Put("Subject","@" + Dpt.get("Departure_Manager").get("name") + ": perform 'Status=Guaranteed steps' for " + Dpt.get("Name"));

task.Put("Due_Date",today.addDay(3));

task.Put("Priority", "High");

task.Put("Description", "bla bla");

task.Put("What_Id",DepartureID);

//

info task;

resp = zoho.crm.createRecord("Tasks",task);

info resp;


The first info statement shows:

{"Subject":"@Peter Mienes: perform 'Status=Guaranteed steps' for testMicro 2021 (8/8)","Due_Date":"11-Aug-2021","Priority":"High","Description":"bla bla","What_Id":2506960000040326864}


The second info statement shows:

{"code":"MANDATORY_NOT_FOUND","details":{"api_name":"$se_module"},"message":"required field not found","status":"error"}

  1. I've checked the API name of the Related To field in the Tasks module: the API name is What_Id, data type is Lookup.
  2. If I comment out the last Put statement, i.e. task.Put("What_Id",DepartureID), then the task is created successfully. So the problem is in the way I'm defining the Related To field.

Anyone who can help me understand why I get an error message?

Thanks,

Peter