Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Script object in fragment not working?


Level 2
I have a fragment that contains a script object and a text field. The text field's initialize event handler calls a method in my fragment's script object. Everything works fine in preview mode of the fragment.

When I create a new file and use the fragment in that file, the initialize event handler in my fragment is invoked just fine, but the method I'm trying to call in the script object in the fragment never fires. What I have looks like this:


- fragment


- script object "Foo"

- someMethod()


- text field::initialize


- Foo.someMethod();

When I preview the fragment, I get "hello" and "Foo" message boxes.

When I preview the file, I only get the "hello" message box.

Is what I'm trying to do possible?


3 Replies


Level 10
When calling the script object that is embedded in the fragment you have to path specifically to that object. The scriptobjectName.method is not enough to find what you want. You would need FragmentName.ScriptObjectName.Method()

I tried it here and it worked.

You may want to use a script Fragment instead of using an embedded script object on a fragment. The script fragment would run in the form root context and would behave like you are expecting.


Level 2
Hi Paul,

Thanks for the quick response. For the script fragment approach, would I insert the script fragment into the file, or can I put it in my content fragment?




Level 10
Put it in the file so that it is at the root of the file. It will act like any other fragment (the designer cannot edit it unless they have access to the fragment source) and it will be resolved when the form is rendered, so any updates are picked up right away.