Connect Custom Module with Contacts via MultiSelect and Deluge

Connect Custom Module with Contacts via MultiSelect and Deluge

I have created a custom module called "Customer Account Plan" which is created by a button on the Accounts module; this button will auto complete several fields as it's creating the record.

I want to associate the Contacts that are relevant to this Account to the newly created "Customer Account Plan" record... but I'm getting a bit stuck. I have created a multifield lookup, and I want it to be populated when the button is pressed.

How can I pass all of the Contacts that match the Account into the new record.

  1. // Find Linked Contacts
  2. varContactDetails = zoho.crm.getRelatedRecords("Contacts","Accounts",custid);
  3. //Create a list of just the matching Deals IDs
  4. varContactIDs = List();
  5. for each  varContact in varContactDetails
  6. {
  7.     varContactIDs.add(varContact.get("id"));
  8.     mp.put("Contacts_Field",ifnull(varContactIDs,""));
  9. }

I get the error :
{"code":"INVALID_DATA","details":{"expected_data_type":"jsonobject","api_name":"Contacts_Field","json_path":"$.data[0].Contacts_Field[0]"},"message":"invalid data","status":"error"}

There could be more than one contact to add.
I'm fairly new at CRM Deluge so any advise is welcome