Using Now Assist for Creator to Create Transform Script

jasonutah
Tera Contributor

Using Now Assist for Creator to create a transform script, we used the following prompt:

write a transform script that uses JSON payload fields u_employee_name, u_employee_number, u_date_worked from the bulk_data column of the x_g_soud_cus_proje_import table. Parse multiple records and insert each into target table x_g_soud_cus_proje table.

The following script generated looks pretty good:

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    var bulkData = source.u_bulk_data;
    var jsonData = JSON.parse(bulkData);
    var records = jsonData.records;

    for (var i = 0; i < records.length; i++) {
        var record = records[i];
        target.u_employee_name = record.u_employee_name;
        target.u_employee_name = record.u_employee_number;
        target.u_date_worked = record.u_date_worked;
        target.insert();
    }

})(source, map, log, target);

 

This script was added to a transform map as an onStart script. This transform map is connected to a REST API web service. We can confirm the API endpoint is working, the import table bulk data field is populated. Multiple tests show that the bulkData value from source.u_bulk_data is undefined. The target table is not populated. Also, a test where we hard code values to bulkData, the target table is still not populated.

 

Any ideas on what steps may be necessary to fix this transform map and script? 

 

0 REPLIES 0