Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

What will happen if column is missing on staging table

Abhijit Das7
Tera Expert

Hi Everyone,

We had a column on the staging table called Response SLA Source (u_response_sla_source). The column name existed in the system, but its label was missing. Because of this, the field was not visible in the list view, form view, or even in the Show XML output.

To investigate the issue, we engaged ServiceNow support. Around 29 August, they removed the original field and recreated it with the same column name (u_response_sla_source) but with a proper column label.

We have several field mappings that use scripts, and some of those scripts include a condition similar to:

 

if (source.u_response_sla_source == 'cvc')


As there is no else loop after if loop and u_response_sla_source is empty, it has started giving error.

Prior to 29 August, this condition never caused any issues. However, after the field was recreated, the code started evaluating this condition, and we began seeing the following error when the field value is empty:

Reference field value for alm_asset.model rejected: undefined

This occurs in the field mapping for the Model field on alm_asset. Since the choice action for the reference field is set to Reject, the record update is stopped whenever the script returns undefined.

My question is: What changed on 29 August that caused this behavior? More specifically, if the field effectively did not exist or was not accessible before, why was the condition not causing any issues previously, yet after the field was recreated the same code path started executing and resulting in errors?

Has anyone encountered similar behavior with recreated staging table fields or field mappings in ServiceNow?


@Ankur Bawiskar - Can you please guide me on this.

Thanks in advance

4 REPLIES 4

henry45cavi
Mega Contributor

Hello,

Because the field is now functional, your script is actively evaluating the incoming data. When records arrive where u_response_sla_source is empty or does not match 'cvc', the script processes the condition rather than bypassing it entirely.



Best Regads

yashkamde
Giga Sage

Hello @Abhijit Das7 ,

 

Try adding else branch in the field map script, it was always a latent bug, just masked earlier because the broken field prevented the script from resolving cleanly.

if (source.u_response_sla_source == 'cvc') {
    answer = <cvc logic>;
} else {
    answer = <default/existing value to use when blank>;
}
//Apply this to every field mapping script using the same pattern, not just this one.

 

If my response helped mark as helpful and accept the solution.

Tejas Adhalrao
Kilo Sage

hi @Abhijit Das7 ,

Most likely, the field map was not running earlier because the column had no label, so no value was being returned and Model remained unchanged.

Once the field map was recreated correctly, it started executing, encountered the empty value, returned undefined, and the reject stopped the record.

I would check the import logs before 29 August to confirm whether there was any Model mapping activity for those rows.

One more point: since Model is a reference field, I would keep the existing target value as the fallback rather than using a default sys_id.

If this helps, please mark it as Helpful and accept the solution.
Regards,
Tejas

Shahjay
Kilo Guru

Hi @Abhijit Das7,

What changed on 29 August is that `u_response_sla_source` became a normal, readable field again.

Before that the column existed in the dictionary but had no proper label. In that state `source.u_response_sla_source` wasn’t behaving like a normal element — either the comparison never really resolved the way you’d expect, or the line was erroring and the transform engine was swallowing it per-row. Either way, nothing useful was being returned for the Model mapping, so the Reject rule never had an invalid value to complain about.

Once Support deleted and recreated the column with a real label, the field became a normal empty string on rows with no value. The `if` now runs to completion. Because there’s no `else` and no final return, the script leaves `answer` unset on the empty path. Model is a reference field with Choice Action = Reject, so an unresolved value fails the row. That’s the literal `undefined` you’re seeing in the error.

Fix the field map script so every path sets `answer` explicitly, something like:


answer = (function transformEntry(source) {
    if (source.u_response_sla_source == 'cvc') {
        return /* whatever value you actually want for Model */;
    }
    return '';   // or return current.model if you only care about updates
})(source);


If a blank SLA source should mean “skip this entire row”, put that logic in an onBefore script with `ignore = true` instead. That skips the whole record, so only do it if that’s really the intent.


Also worth checking the other field map scripts on this transform that reference `u_response_sla_source`. If one of them had this gap, the others probably do too — and they’ll start failing the same way now that the field is evaluating normally.


(One honest caveat: whether the pre-29-Aug script was evaluating false silently vs throwing and being swallowed is inference from the symptoms. Old rows in the import set / transform history would settle it if anyone still has them.)


Hope that helps.

If this response helped, please mark it as correct and close the thread ✅ — it helps future readers find the solution faster.

Thanks