Skip to main content

I need to auto-populate a form with existing data from a SharePoint 2016 list. I am using a Custom Javascript to fill the form. I have a repeating section that I need to add to the control on different rows. I've tried using the script: NWF$(".TAP_CSS").find('a').click(); but it doesn't add a row.

Here is what I want to do (using the (a).click(), if it worked)

var varTAP_FLAG = NWF$('#' + TAP_FLAG_JAVA).val();
NWF$('#' + WATER_TAP_FLAG_JAVA).val(varTAP_FLAG);

var varTAP_AMT = NWF$('#' + TAP_AMT_JAVA).val();
var varTAP_AMT = varTAP_AMT/100+".00";
NWF$('#' + WATER_TAP_AMT_JAVA).val(varTAP_AMT);


NWF$(".TAP_CSS").find('a').click();
var varTAP2_FLAG = NWF$('#' + TAP2_FLAG_JAVA).val();
NWF$('#' + WATER_TAP_FLAG_JAVA).val(varTAP2_FLAG);

var varTAP2_AMT = NWF$('#' + TAP2_AMT_JAVA).val();
var varTAP2_AMT = varTAP2_AMT/100+".00";
NWF$('#' + WATER_TAP_AMT_JAVA).val(varTAP2_AMT);

Some help would be greatly appreciated.

Ray Donovan

Command to add row to repeating section:

NWF$(".nf-TAP_CSS").find("a.ms-addnew.nf-repeater-addrow-link.nf-ignore-for-calc").click();

where .nf-TAP_CSS should be the css name defined in the repeating section

Command to assign value to a control inside repeating section

NWF$(".nf-TAP_CSS .nf-repeater-row:last .nf-TAP_FLAG_JAVA").find("input").val(varTAP_FLAG);

where nf-TAP_FLAG_JAVA is CSS of the control inside repeating section.

Syntax:

NWF$(".css-class-of-your-repeating-section .nf-repeater-row:last .css-class-of-contorl")

Hope this helps!


Hi Ray Donovan

Have a look at this Using Javascript to update a repeating section

This may help with your requirement

javascript‌


I tried the code but it still doesn't seem to work. here is what I have:

Repeating Section TAP_REP

      CSS Class: TAP_CSS

Control inside TAP_REP Repeating Section: TAP_FLAG_REP

         Choice field: N or Y

         CSS Class: TAP_FLAG_CSS

         JAVA Var: WATER_TAP_FLAG_JAVA

Java Script:

var varTAP2_FLAG = NWF$('#' + TAP2_FLAG_JAVA).val();
NWF$(".TAP_CSS").find("a.ms-addnew.nf-repeater-addrow-link.nf-ignore-for-calc").click();
NWF$(".TAP_CSS .nf-repeater-row:last .TAP_FLAG_CSS").find("input").val(varTAP2_FLAG);

It doesn't add a row to the repeating section and doesn't add the value either.

Some help would be greatly appreciated.

Ray Donovan


NWF$(".TAP_CSS").find("a.ms-addnew.nf-repeater-addrow-link.nf-ignore-for-calc").click(); can you debug this in the browser using Debugger Tool(F12) and share a screen shot?

Since the control inside the repeating section is a choice the way to access is different as mentioned below:

NWF$(".TAP_CSS .nf-repeater-row:last .TAP_FLAG_CSS").find('input:checked').val() // to get choice selected value

NWF$(".TAP_CSS .nf-repeater-row:last .TAP_FLAG_CSS").find('input').prop('checked',true); // to set to Yes

NWF$(".TAP_CSS .nf-repeater-row:last .TAP_FLAG_CSS").find('input').prop('checked',true); // to set to No

choice field‌ repeating sections‌


Reply