Script transform calling script library function resulting in AttributeErrors

Hello,

I ran into an issue where I used a script transform on a dock that calls a function from the script library. It worked in testing, but when I put it into production, I quickly started getting binding overlays and errors in the logs that said something along the lines of:

AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute system.dataset.toDataset

Here is the function:

def dropDownFormatter(dataset, valueFirst):

   if dataset is None:
      return dataset

   columnCount = dataset.getColumnCount()

   if columnCount < 2:
      return dataset

   headers = ["value", "label"]
   data = []

   for row in range(dataset.getRowCount()):
      if valueFirst:
         data.append([
            dataset.getValueAt(row, 0),
            dataset.getValueAt(row, 1)
         ])
      else:
         data.append([
            dataset.getValueAt(row, 1),
            dataset.getValueAt(row, 0)
         ])

   return system.dataset.toDataSet(headers, data)

From IA support:

"The issue effects script transforms primarily because script transforms are compiled and executed on the fly, each time the binding fires. This means they hit the class-loading/injection process repeatedly and unpredictably, making them far more likely to catch the race condition window where system hasn't been fully resolved yet."

Based on what they tell me, this is a known bug.

They also indicated that having any import system calls in our codebase will cause these issues. What's interesting is there was no import system in the script transform library, but there are instances of it in some existing code.

It seems like script transform library calls are especially susceptible to this, so I just put my transform logic right in the script transform dialog window. I was trying to create a reusable script transform library but for now I'd rather the code just work consistently.

I've seen general advice on the forums to never use import system in scripting logic:

Can anyone weigh in on the reason to not use import system in any scripts? Also, has anyone else had issues using a script library call from a script transform?

Fixed in 8.3.