Custom Field Value always resets to default or previous value

I’ve just created 2 custom field values for my tickets that need to be updated based on the success (or failure) of a particular custom script. The portion of the code that does this is the following:

      Field => 'Sync Status',
      Value => 'Not Ok'

The code works fine and updates the field’s value but it then automatically returns to the previous value.

If the field was blank before I get the following message: ‘Not Ok’ is no longer a value for ‘Sync Status’. While if the field had a previous value I get this one: Sync Status ‘Not Ok’ changed to ‘Previous Value’.

FYI: I have the same problem with 2 different custom fields that were both created with different parameters one has “Combobox: enter or select one value” while the other has “Fill in one text area”.
I’ve also tried adding RecordTransaction => 1 to the code after setting the new values, to no success.

This may be a result of a known but bug that was fixed in the branch /4.4/not-apply-scrip-batch-in-nested-atomic:

You could try applying that diff as a patch and test with setting the scrip stage to ‘batch’ mode

I actually set the script’s condition to On Transaction and this got fixed, this is a real problem though cus I really need this particular script to run On Queue Changes, not On Transaction.