OK, I understand the use case, thanks also for sharing the script.
This is a very big one, so I don't have time to try to fix one part to explain how to do it.
What I can say is this: you do not need and should not be using the API to process Integrity items in this script.
Everything you want to do can be achieved with the java beans provided for triggers. Have a look at an example script provided on the server like "postLinkedIssue.js". I picked that one because it creates and updates items.
In it, you find code like: newIssue.setFieldValue(description, newDescription)
All the java beans you need are documented in "Event Trigger Java Documentation" on your server's home page. They can be used create items, edit rich text fields, manipulate attachments, etc.
The main one is "ScriptIssueDeltaBean", have a look at all the methods available to you there. I can see you've defined a "delta" variable, now you have to use it. Please do not use the API.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

