Page 1 of 1

scriptFunction and types

Posted: Tue Apr 11, 2017 12:02 pm
by cosmo12

We want to increment a custom field of a work item when transitioning to a certain state.
The custom field is an Integer type, called versionAsInt.
We've added a script containing the following:

var wi = workflowContext.getTarget();
// Get the value of the custom field, increment with 1 and write back.;

Obviously it is the commented line causing us some problems... Among other things, we've tried the following:

wi.setCustomField("versionAsInt", wi.getCustomField("versionAsInt")+1);
Which failed with "...72.0 is not instance of java.lang.Integer" (versionAsInt was 71)

wi.setCustomField("versionAsInt", (Integer)(wi.getCustomField("versionAsInt")+1));
Which failed with "...Integer" is not defined in <eval> at line number 44..."

wi.setCustomField("versionAsInt", Integer.valueOf(wi.getCustomField("versionAsInt")+1));
Which failed in the same way.

Integer verNbr = wi.getCustomField("versionAsInt");
verNbr = verNbr+1;
wi.setCustomField("versionAsInt", verNbr);
Which failed with ..."Expected ; but found verNbr Integer verNbr;..."

We do however see that the field is updated if we turn it into a string (but then appended with '1', so 7 becomes 71, becomes 711 etc).

Any ideas would be highly appreciated.