text: What's wrong with this script?
  That's quite a script to troubleshoot without any additional information.
  What's the context? What's the workflow? Does it work at all? If so, what is the expected behavior compared to what it's actually doing?
  Does it throw an exception? If so, what is it?
  What are you sending to the API? What are you expecting back?
  What troubleshooting steps have you taken so far (if any)? What were the results of your troubleshooting?
  The more information, the better.
  It can sometimes prove impossible to troubleshoot other people's scripts because we don't have much (if any) information about their tables, fields, field types, relationships, etc.
  On top of that, it can prove incredibly difficult when people don't give us any context into the workflows that the script might be affected by or be integrated into. The context of any relevant workflows can completely change the design pattern of a script that might be best suited for a certain implementation.