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!
- void automation.UpdateChangeHistory(Int recordId, String moduleName, String textFieldName, String dateTimeFieldName)
- {
- updateMap = Map();
- updateMap.put(textFieldName,zoho.loginuser);
- updateMap.put(dateTimeFieldName,zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ss'+00:00'"));
- info updateMap;
- update = zoho.crm.updateRecord(moduleName,recordId,updateMap);
- info update;
- if(update.get("status") == "error")
- {
- info "Error updating record: " + update.get("message");
- }
- else
- {
- info "Record updated successfully";
- }
- }