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 (Functions) operation.

Not applicable

7 Replies
Not applicable
I have created a function called CountMeds which counts number of medications in a column of a table. I have followed all the formatting rules (including curly braces, ensuring everything is javascript, etc.). This script object exists at the highest level of the form hierarchy (created by LC). There are no errors in this script object. When I invoke CountMeds as part of a Button click script (As in CountMeds(a,b) the function is NOT executed.

What am I doing wrong?
Level 10
Level 10
I assume the function is called CountMeds. So you would need to call the function as:


If this is not it hit Ctrl-J and see what the JavaScript debugger indicates.
Not applicable
Yes the function is called CountMeds. In the Hierarchy view it shows up as part of subform "PtMedReconForm" which contains an un-renamable object called variables. It looks almost exactly like the picture in LC Designer Help under topic "Scripting > Scripting Using LiveCycle Designer ES > Creating and Reusing JavaScript Functions > To create a script object".

So in your example what would be "myScript" and what would the "ObjectName" be? Ctrl-J has no effect!

As always your rapid response and expert guidance is deeply appreciated!
Level 10
Level 10
In the Hierarchy view click on the object, hit F2 and it will allow you to rename it. Change it to myScriptObject. Now you shoudl be able to call it by myScriptObject.CountMeds();

If that dies not work copy all of the code to the clipboard. In the hierarchy view choose the root node. Right mouse click and choose the insert script object. Now rename it as above and paste you code into this object.

Lastly, put an app.alert("This is a test") as the 1st line in the script object. Execute your button and see if the message pops up. This will tell us if the object is even being called.
Not applicable

1. F2 button does not work!

2. I copied all the code and when I clicked on the Root node to insert script object it invariably pastes it under the same variable where it pasted CountMeds before. I can rename the newly pasted script Object but still can't rename the variable! 😞

I have put lots of app.alerts in the script to track its progress! Actually that is how I figured out that the function (script object) wasn't executing!

Once I get the function call to execute properly I think I will be on my way!

Sorry this is turning out to be such a pain but then if it had been simple I wouldn't have bothered you!
Level 10
Level 10
The variables node cannot be renamed .....I was asking for the scriptObject to be renamed. So you should be calling your function by using scriptobjectname.functionname.

If that still does not work, post your form to and I will have a look.
Not applicable
Thanks Paul! That works beautifully! I had named both the script object and the function with identical names and hence could not "see" the difference!