Good morning
I am trying to reset ONE field in a repeating subform. I don't want to hide the instances of the subform for this action, or re-set the entire form.
The field I wish to reset is form1.Main.sfOMKT.Table1.Row3.sfFigs.numFigures and sfOMKT is the repeating subform which it lives in.
Obviously this works great for the first instance: xfa.host.resetData("form1.Main.sfOMKT.Table1.Row3.sfFigs.numFigures");
But no matter how much I read I cannot grasp the referencing thing...
Would anyone be able to help?
Solved! Go to Solution.
Views
Replies
Total Likes
I am assuming by resetting the field, you want to set its value to null or empty.
Then try this script.
var subforms = this.resolveNodes(" form1.Main.sfOMKT[*]"); for(var i =0; i<subforms.length;i++) {
subforms.item(i).Table1.Row3.sfFigs.numFigures.rawValue = ""; }
I am assuming by resetting the field, you want to set its value to null or empty.
Then try this script.
var subforms = this.resolveNodes(" form1.Main.sfOMKT[*]"); for(var i =0; i<subforms.length;i++) {
subforms.item(i).Table1.Row3.sfFigs.numFigures.rawValue = ""; }
Works beautifully. Again you save me
You need to specify the instance's index of the repeating subform to target.
so if the action is triggered by an event linked to a cell in the same row as the field to be reset,you could do something like this:
// determine the index of the targeted instance of the repeating form
var TargetIndex = this.parent.parent.parent.index;
// create the string representing the SOM of the targeted field
var TargetCell = "form1.Main.sfOMKT["+TargetIndex+"].Table1.Row3.sfFigs.numFigures";
// reset the value of the targeted cell
xfa.host.resetData(TargetCell);
Hi,
you can use the resolveNodes() method, to reference multiple instances in an object.
Here's an example. You're creating a node list for all instances of sf0MKT named oSubforms.
Then you're using a for loop to process every node in the list.
var oSubfoms = form1.Main.resolveNodes("sfOMKT[*]), i = 0; for (i; i < oSubfoms.length; i += 1) { var oNode = oSubform.item(i); oNode.Table1.Row3.sfFigs.numFigures.rawValue = null; }
Thank you so much!!! I don't know where I would be without this forum.
For a self starter I have made some pretty decent bespoke forms for my organisation largely thanks to the help of you guys here when I hit a roadblock.
I really want to understand how you know to use stuff like this
for (i; i < oSubfoms.length; i += 1) {
Can you recommend anything for a total beginner for JS? Course, reading material? I read a LOT of stuff and sometimes can work it out for myself, but I lack the basic knowledge so I don't think I will ever progress until I get that base....