You're not passing any parameters to your query, so it just sends nulls instead.
You need to pass a dict containing keys that match your query parameters:
params = {
'Trailer': value_for_trailer,
'Batch': value_for_batch
}
system.db.runNamedQuery(query, params)
Also, take a look at this:
This thread is intended as a short help file for all those struggling to post formatted code on the forum.
Code block formatting
Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the </> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting.
[How to post code]
Note that all the </> button does is add three backticks ``` on the line before the code block and anot…