I have a workflow initiated by a button click doing some java script calculations (Toolbox) and then saves the values to my DB. The strange thing is that the correct values only gets properly saved if I click the button twice, or if I run the workflow while debugging step by step or slow.
Seems like a timing issue, but that makes no sense to me because:
The result of my “Run Java script” calculation is stored in a “Java script to bubble” element.
The “make changes to thing” is saving this elements value.
On my page I created two text fields… one shows the “Things field value” and the other one the J2B elements value. They both show the correct result after button click…
But after a second or two, the text referencing the things field value switches to show the previous value stored in the field.
The text showing the J2B elements value is still showing the correct value ???
In my mind, if the text displaying the DB things field shows the correct value before reverting to the old one, it must somehow be written to the DB. The workflow tells me it is.
Has anyone encountered a similar problem ? Is it a bug ?
Step 1: (this is just creating and stingifying my JSON string for saving in a text field… Works fine/saves fine)
let myObject = ;
let counter = List LENGTH (J2B)'s value;
let tankName = [“List tankname (J2B)'s value list join with “,””];
let tankVolume = [List tankvolume (J2B)'s value list];
let tankStatus = [“List tankstatus (J2B)'s value list join with “,””];
let temperature = [List temperature (J2B)'s value list];
let bg = [“List bg (J2B)'s value list join with “,””];
let comment = [“List comment (J2B)'s value list join with “,””];
let animal = [List animal (J2B)'s value list];
let egg = [List egg (J2B)'s value list];
let eggPst = [List egg_pst (J2B)'s value list];
let chlorella = [List chlorella (J2B)'s value list];
let ff = [List ff (J2B)'s value list];
let pads = [List pads (J2B)'s value list:formatted as text];
let medication = [List medication (J2B)'s value list:formatted as text];
let experiment = [List experiment (J2B)'s value list:formatted as text];
let flow = [List flow (J2B)'s value list];
let type1 = [“List type1 (J2B)'s value list join with “,””];
let type2 = [“List type2 (J2B)'s value list join with “,””];
for (i=0 ; i < counter; i++){
let tankObject = {
tankname : tankName[i],
tankstatus : tankStatus[i],
animal : animal[i],
egg : egg[i],
egg_pst : eggPst[i],
chlorella : chlorella[i],
ff : ff[i],
temperature : temperature[i],
bg : bg[i],
type1 : type1[i],
type2 : type2[i],
flow : flow[i],
experiment : experiment[i],
pads : pads[i],
medication : medication[i],
comment : comment[i],
tankvolume : tankVolume[i]
}
myObject.push(tankObject);
}
let myJson = JSON.stringify(myObject);
bubble_fn_thisJSON(myJson);
STEP 2 : This is the calc that returns the values that im having a hard time getting to save correctly
const thisJSON = JSON.parse(‘Current Workflow text’);
//CALCULATE AMOUNT OF NEW ANIMALS
let newAnimals = thisJSON
.filter( tank => tank.tankvolume === 2000 )
.reduce( ( tot, add ) => tot + add.animal, 0) * 2 * 1000 * 1000;
//CALCULATE HOW MANY ANIMALS ARE DRAINED
let outAnimals = thisJSON
.filter ( tank => (tank.tankstatus === “M” || tank.tankstatus === “E” || tank.tankstatus === “K”))
.reduce((tot, add) => add.tankstatus !== “M” ? tot + add.animal : tot + add.animal * 1.2, 0) * 1000 * 1000;
//CALCULATE CHLORELLA AMOUNT PER DAY
let chlorellaTotal = thisJSON
.reduce ((tot , add) => tot + add.chlorella, 0) * 60 * 24 / 1000;
bubble_fn_dyrNye(newAnimals);
bubble_fn_dyrUt(outAnimals);
bubble_fn_chlTot(chlorellaTotal);
STEP 3 : Saves all the values (Everything but the three last values saves fine)
I find the problem strange because after button click → workflow… The J2B element on the page still holds the correct value…but the DB value flips back to it’s old state after a couple of seconds
Not easy to debug such a thing either… The server logs does not hold any information on whats going on
Any help/insights highly appreciated ![]()







