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

SOLVED

Verify last instance of a textfield is not null

Avatar

Level 9

I have a repeating subform that includes a textfield for the user to enter their name. When the user clicks a custom email button to send the form I want to first verify if the last instance of that field was populated (not null). I don't care about the previous instances only the last instance. The custom email button is pushed down below each instance of the subform so it is always just below the last instance of the repeating subform. Is there a way to refer to the last instance of a subform field when i don't know how many instances will be created?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi DKinsley,

I think the following steps and code will solve your problem.


1) In order to know the last instance, you need to find the count of instances available. This can be achieved through the following code"

var totalRowInstances = xfa.resolveNode("form.Name.txtName").instanceManager.count;

2) To access the last index value,

     var lastIndex = totalRowInstances-1;

//[Since the index always starts with 0]

     var lastIndexNameCheck = xfa.resolveNode("form.Name["+lastIndex+"]").txtName.rawValue;

     if(lastIndexNameCheck != null)
     {
           //do something
     }
     else
     {
           //do something
      }

Please Note : Here, form - refers to root node, Name - refers to subform, txtName - refers to name of the text field.

Please let me know if this helped.

Thanks,
VJ

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

Hi DKinsley,

I think the following steps and code will solve your problem.


1) In order to know the last instance, you need to find the count of instances available. This can be achieved through the following code"

var totalRowInstances = xfa.resolveNode("form.Name.txtName").instanceManager.count;

2) To access the last index value,

     var lastIndex = totalRowInstances-1;

//[Since the index always starts with 0]

     var lastIndexNameCheck = xfa.resolveNode("form.Name["+lastIndex+"]").txtName.rawValue;

     if(lastIndexNameCheck != null)
     {
           //do something
     }
     else
     {
           //do something
      }

Please Note : Here, form - refers to root node, Name - refers to subform, txtName - refers to name of the text field.

Please let me know if this helped.

Thanks,
VJ

Avatar

Level 9

This appears to work well - thanks so much.