Update a related list with custom function.

Update a related list with custom function.

Hi, we are triying to update a related list inside a Lead using a custom function. When a lead is created or edited, a rule is triggered which executes the custom function. This function takes two arguments: the lead ID and the value inside a field called "titulacion". Titulacion has the same value as the product we want to relate. The code is the following:

criteria = "(Product_Name:equals:"+ titulacion+ ")";
producto = zoho .crm.searchRecords( "Products", criteria);
producto = producto .get( 0);
productoID = producto .get( "PRODUCTID");
response = zoho .crm.update( "Leads", ID,{ "Products": productoID});

When we test the code, it's executed successfully, but the related list remains the same with no changes.