Of course - it works perfectly in 12.
You indicated that it "works perfectly" with script debugger but fails when run normally, which suggests to me that you are stepping through it when using debugger.
- Does it work in debugger if you don't step thru but just use pause on error only?
- Does your script include a commit record step after the chart has been placed into the global container?
I've done this in 11 and 12. The key, at least in my case, was a slight pause (like 0.1 second) seemed to be required. No idea why, but placing a Pause Script step in there after the Refresh Window seemed to make it work.
I would try as Mike suggested. Include the slight pause. I often find a pause necessary when you are handling something that is dependent upon the screen redrawing.
Another option, or perhaps a combination of both, I would test using the Freeze Window script step instead of Refresh Window. I very rarely use Refresh Window, because of the effect it has on Windows users. Freeze Window does what I need 99% of the time. And in many instances, can be used instead of a Pause Script - Refresh Window to achieve the desired result.
I had the pause in the wrong spot. Two script steps - the sort and then the set field to grab the chart and put it into the container. I had the pause after the set field step. As soon as I moved it to BEFORE the set field step it worked fine.
Bingo. The pause is there to allow the chart object to render. I think. At least that's my rationalization for why it works.