Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Determine Which Node an Event has Occurred?

Avatar

Level 1

Hello Experts! I currently have a repeating subform that generates a new instance for each row in a table that I am importing. I am attempting to have some field values change based on an even that occurs in another field, and these changes need to be specific to the instance where they occurred. I will be putting my code in the CHANGE event and was wondering if there is a way to determine which node the change is occurring in. If you require further clarification/explanation please let me know, I'm at somewhat of a roadblock because of this issue and would really appreciate the help, thanks!

2 Replies

Avatar

Level 1

As a quick follow up, here's the code I am currently using which loops through each node and is supposed to make changes accordingly. If there is no way to determine which node an event is occurring on, then I don't mind going the loop route but for some reason this loop is not having the desired effect. This code is hit in the CHANGE event for nodeName1, and I'm getting strange behavior where making a change in one instance of my subform will have an effect in the other instances.

data.Page.DATA.USER_INPUT.RECV_CU_WGT::change - (JavaScript, client)

var nodeCount = data.Page.dataNode.resolveNodes("DATA[*]").length;

for(var i = 0; i < nodeCount; i++){

     var nodeName1 = "data.Page.DATA["+ i +"].USER_INPUT.RECV_CU_WGT";

     var nodeName2 = "data.Page.DATA["+ i +"].USER_INPUT.RECV_CU_WGT_UOM";

     var nodeName3 = "data.Page.DATA["+ i +"].USER_INPUT.RECV_CU_WGT_PER";

     var nodeName4 = "data.Page.DATA["+ i +"].USER_INPUT.RECV_CU_WGT_PER_UOM";

     if(xfa.resolveNode(nodeName1).rawValue == null){

          xfa.resolveNode(nodeName2).mandatory = "error";

          xfa.resolveNode(nodeName3).mandatory = "error";

          xfa.resolveNode(nodeName4).mandatory = "error";

}

if(xfa.resolveNode(nodeName1).rawValue != null){

     xfa.resolveNode(nodeName2).mandatory = "disabled";

     xfa.resolveNode(nodeName3).mandatory = "disabled";

     xfa.resolveNode(nodeName4).mandatory = "disabled";

}

}

Avatar

Level 7

If you can provide a screenshot of the hierarchy, I may be able to make this advice more specific.

Are you changing something in the same instance where the change event occurs? If so, using .parent to walk up the hierarchy may a useful option for you. If you have a subform that repeats and two nodes inside called tfSomething and tfSomethingElse, and you want to have the exit event for tfSomething affect the other, then this.parent.tfSomethingElse will always hit the tfSomethingElse in the same subform.

Are you changing something in another subform/container that is indexed the same as the place your event occurs? Then you could use this.parent.index to get the index of the subform/container that holds the node with the event.

One of these two methods keeps you from having to worry about exactly which node is generating the event in almost all cases. Again, if this doesn't help, a screenshot can help us give you a better idea of what to do.