Troubleshooting K-fields

Here are some common K-field issues and how to troubleshoot them.

Missing semicolons

While editing the calculation, a cross image can indicates a missing semicolon.

A function with a missing semicolon after the last brace character

Include a semicolon after closing the brace.

Same function, but with the semicolon after the last brace character

Duplicate K-field names

The label (identifier) for a K-field must be unique; when it is a duplicate of an existing K-field, this error occurs:

Error: "Expected to create by key, but found [...k_field_name]"

No return function

Make sure to add return for return type:

Error: "The returned value is Undefined" happens when there is no 'return' statement in a function

Feedback fields not backfilled

While using standard JavaScript functions, Feedabck fields must be backfilled, otherwise it may result in an error stating the Unknown global variable:

Examples of the error messages: "Unknown global variable q_completed", and "ReferenceError: 'q_completed' is not defined (__script__#2)

Testing with different survey results

Check the result using a Survey ID (if responses are available) for a response:

Running a test against survey ID 137013; click Run to see the results of the function against the survey record

The example above is testing the result for Survey ID 137013. Use different IDs to validate the calculation against different results.

Using the Seqnum function

When using the seqnum function in the K-field, the seqnum being returned should be mapped to the numeric value and the result is not relevant:

f = function() {
    var store_wait = seqnum(q_fulfillment_osat_store_wait_time_11pt_sat);
    var survey_type = seqnum(e_target_survey_type_alt);

    //Check for Drive up
    if(survey_type == 32){ 
        return store_wait; 
    } else { 
        return null; 
    }
};
f();