Custom Function - Create Record in custom module with a Contact Look Up field

Custom Function - Create Record in custom module with a Contact Look Up field

Hello, I script a custom function linked to a butom, in Contacts (contact view) that creates a record in a Custom Module.
I need to pass the contact name to link this new record with the contact.

The next code works fine the first time, but if I delete de created record and I repeat de custom function (clicking the buttom again) doesn't work well. Create the record without the contact name.

This is the code:

  1. nombre_Cliente=input.firstName;  // from Contacts
  2. apellidos_Cliente=input.secondName;  // from Contacts
  3. cliente=nombre_Cliente + " " + apellidos_Cliente;
  4. mapaMovCaja=map();
  5. mapaMovCaja.put("Cliente",cliente); // 'Cliente' is the Contact Lookup field name
  6. crmMovCaja = zoho.crm.create("CustomModule1",mapaMovCaja,2);

Please, why this code works well first time but doesn't if I delete the record and try again.

I need a stable solution that works every time I click the buttom in Contact view.

Thank you very much in advance.

Best Regards  :)