Ask Your Question

How can I access each record field and its value in JavaScript?

asked 2019-01-30 14:12:07 -0500

iamontheinet gravatar image

I am using JavaScript Evaluator processor in my pipeline and I would like programmatic access to each record field and its values in a loop. How can I achieve that?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-01-30 14:13:49 -0500

iamontheinet gravatar image

You can use the following JavaScript code to iterate through each record (field,value) pair:

  try {
    // Access each record field and its value    
    var record_dictionary = records[i].value;
    for (var field in record_dictionary)  {
      var field_value = record_dictionary[field];"=== field: {} | value: {}",field,field_value);

      // do something... 

    // Write record to processor output
  } catch (e) {
    // Send record to error
    error.write(records[i], e);

Cheers, Dash

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-01-30 14:12:07 -0500

Seen: 34 times

Last updated: Jan 30