"cannot convert null to an object" in a triggerscript
Hi @all,
i'm now outing me as a non-programmer
We have following problem: in an item were three datefields. The first field should be filled by the user, and the other two fields should be computed by a rule. Because filling a datefield by a computation it is not editable anymore we wanted to use a trigger to do this.
This works fine unless the user doesnt fill the first datefield. Then we get a javascript error:
"Internal Error: undefined: Cannot convert null to an object."
Here comes the code from the triggerscript:
try
{
var issue = bsf.lookupBean("imIssueDeltaBean");
var params = bsf.lookupBean("parametersBean");
var fieldDueDate = params.getParameter("Startfeld");
var CompValue = params.getParameter("Anzahl Tage");
var targetField = params.getParameter("Zielfeld");
}
function main()
{
var StartDate = issue.getNewFieldValue(fieldDueDate);
var StartDate = new Date().setTime(StartDate.getTime()+(CompValue*24*60*60*1000));
issue.setFieldValue(targetField, StartDate); // set field to due date
}
}
The red line is the one which causes the error.
The Trigger-Config has three fields:
- "Startfeld" (the first datefield),
- "Zielfeld" (the target datefield)
- "Anzahl Tage", which holds the Number of days to compute with.
So how we get rid of this Javascript-Error? First we tried to catch an empty field by the trigger-rule with looking for a "Startfeld" != -unspecified-
but this doesnt work. So we tried to get this in the script by an if-statement in the main-function like:
if (fieldDueDate != null)
but this has no effect, this if-Statement is always false.
Other if-Statements were
if (!fieldDueDate)
or
if (!isNaN(fieldDueDate))
are always true, so we never get into the function. Can someone help me, please
? Thanks in advance...
kind regards, Jens

