This workflow task will permit us to create or update records in the application. It is like the create workflow task but not limited to related modules and the update workflow task all in one.
You must select the module you want to create/update the record in. You can only select one module, which means that all the fields you select in the field mapping must belong to the module you select first. If you need to create/update records in different modules you have to add more upsert workflow tasks, each one with one module.
Then you select a condition business map. This condition defines the action that will be taken:
Finally, you have to define a value for each field you want to create and update. Note that since there can be no relation between the module triggering the workflow task and the module where the new record is being created you must establish a value for the relation fields (getIDof is your friend here).
This task has a few interesting tricks up its' sleeve.
The most impressive is that it can loop over a set of rows and upsert for each one. It is the first workflow task that can do this (it won't be the last now that we have context support). If you load an array of values into the upsert_data context variable, the upsert task will loop over each row, evaluate the business map, and upsert accordingly for each one.
For each loop, it loads the data into the context variable: current_upsert_row, so you have access to all the information in each iteration, you can use in the field mapping like this (for example)
If you define a context variable named linkmodeid and set its' value to the CRMID of a record in the application, the new record that is created will be related to that CRMID. This is to easily support many to many relations (Documents for example).
If you load an attachmentdefinition into the virtual "attachments" field, the task will upload the file into the field.
filename | array with these fields: name: string, name of the file to upload, size: file size type: file type content: base64_encode(file) |
Next | Chapter 6: Add/Delete Tags Workflow Tasks.