Functions - How to pass Dynamic Parameters / Arguments?

Functions - How to pass Dynamic Parameters / Arguments?

I am trying to create a generic function that I can use to update a given field with the name of the user and a given field with a datetime.

The purpose of this is to have a history of major actions within the CRM record itself so it is easier to query who and when something was done that trying to use the Timeline data.

I will populate these fields automatically using a combination of Blueprint actions and Workflows.

I thought I could easily create a single function which took the moduleName, textFieldName and dateTimeFieldName fields as params and so I could set these dynamically from wherever I was calling my function form.  However, when I set up my function, it wants the argument values and then it seems to remember them.   So I can't have one step of the Blueprint updating two fields and a later step updating two other fields.

It's going to quickly silly if I have to duplicate this function for every pair of fields I want to populate.
Am I doing something wrong?  Is there another way to do this?

Thanks!

  1. void automation.UpdateChangeHistory(Int recordId, String moduleName, String textFieldName, String dateTimeFieldName)
  2. {

  3. updateMap = Map();
  4. updateMap.put(textFieldName,zoho.loginuser);
  5. updateMap.put(dateTimeFieldName,zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ss'+00:00'"));


  6. info updateMap;

  7. update = zoho.crm.updateRecord(moduleName,recordId,updateMap);


  8. info update;

  9. if(update.get("status") == "error")
  10. {
  11. info "Error updating record: " + update.get("message");
  12. }
  13. else
  14. {
  15. info "Record updated successfully";
  16. }
  17. }