Error message from an IF activity of the workflow: "Wrapped TypeError: Cannot read property "number" from undefined"


Description

Symptoms

Error message from an IF activity of the workflow: "Wrapped TypeError: Cannot read property "number" from undefined"

Release

Any supported release

Cause

Wrong query passed in the Advanced script of the workflow activity

Resolution

The workflow is defined on the 'task_sla' table.
IF activity in the workflow is trying to fetch the parent task and the query defined was:
rec.addQuery('sys_id', rec.current.number);

The query against the 'sys_id' column must have a matching sys_id, instead a number was passed.
This query fails when trying to fetch data and throw the below error message:
"Wrapped TypeError: Cannot read property "number" from undefined"


The line from the script has to be replaced with:
rec.addQuery('sys_id', current.task.sys_id.toString());
OR
we can define a variable and then use the same in the query as below:
var inc = current.task.sys_id.toString();
and then the script should look like:
rec.addQuery('sys_id', inc);