Hello
I am trying to get the TextField1's CAPTION/LABEL/DESCRIPTION (what text user sees on the form, say 'Account #') with the below code but its not working, pls. let me know the syntax to get it
var a;
var b
if (xfa.resolveNode("("VISITOR.PAGE1.Subform1.TextField1").rawValue == null) {
a = xfa.resolveNode("VISITOR.PAGE1.Subform1.TextField1").name;
b = xfa.resolveNode("VISITOR.PAGE1.Subform1.TextField1").id;
{
app.alert( b + " is a required field")
}
}
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You can assign or check the value of a field's caption by using: SOM.caption.value.text.value
if (TextField1.caption.value.text.value == "Text Field1")
{
app.alert("Hello World");
}
That means you can assign the caption to a variable.
In some cases you will need to use the resolveNode() method as is required by the relative SOM and your naming objects. It is not required in many situations.
Also, the "name" attribute of a field can be accessed by using: SOM.name (I haven't tried assigning a new value to the "name" attribute)
As for an .id attribute -- I don't think they exist in xfa.
Good luck!
Stephen
Views
Replies
Total Likes
Hi,
You can assign or check the value of a field's caption by using: SOM.caption.value.text.value
if (TextField1.caption.value.text.value == "Text Field1")
{
app.alert("Hello World");
}
That means you can assign the caption to a variable.
In some cases you will need to use the resolveNode() method as is required by the relative SOM and your naming objects. It is not required in many situations.
Also, the "name" attribute of a field can be accessed by using: SOM.name (I haven't tried assigning a new value to the "name" attribute)
As for an .id attribute -- I don't think they exist in xfa.
Good luck!
Stephen
Views
Replies
Total Likes
Thank you.
Do i need to use SOM in my syntax or not? Say, i hv like below
my_form
my_page
my_subForm
my_text_field1 ===> caption is my_caption
Then how should i get my_caption for my_text_field? syntax pls.
THank you
Views
Replies
Total Likes
You can use a relative-SOM or an absolute SOM
The Script Editor makes it easy by letting you CTRL (relative SOM) or CTRL + Shift (absolute SOM) and click on the object you are referring to. First put the cursor in the Script Editor where your script is. Then, while the cursor is blinking ready for you to type your script, press CTRL and click on the object you need the SOM for.
my_form.my_page.my_subForm.my_text_field1 (absolute SOM for my_text_field1 )
so:
my_form.my_page.my_subForm.my_text_field1.caption.value.text.value //references the my_text_field1 caption using an absolute SOM
or:
my_text_field1.caption.value.text.value //references the my_text_field1 caption using a relative SOM (when the object with the script you are writing is in the same subForm as my_text_field1)
Good luck!
Stephen
Views
Replies
Total Likes
Thank you for ur detailed answer, it worked.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies