Delete rows from nested subform using eFormHelper.deleteRowsFromSubForm

Comments

4 comments

  • Official comment
    Avatar
    AgilePoint NX Support

    Hello Madhu,

    Please use the below code to verify your requirement:

    eFormHelper.getField({fieldId : 'SubForm1/SubForm2'}, function(getResult){
    if(getResult.isSuccess){
    var ctrlArr = getResult.data;
    for(var i = 0; i < ctrlArr.length; i++){
    var subFormCtrlId = ctrlArr[i].getAttribute('id');
    eFormHelper.deleteRowsFromSubForm({fieldId : subFormCtrlId, rowIndex : '*'}, function(deleteResult) {
    console.log(deleteResult);
    });
    }
    }
    });

     

    Thanks,

    AgilePoint Support

    Comment actions Permalink
  • Avatar
    Madhu

    Thanks for the reply and it works upto the point where it loops through and get different SubForm2 ids, however actual deletion is not getting executed.

    I modified function to debug better as below.

     


    eFormHelper.getField({fieldId : 'SubForm1/SubForm2'}, function(getResult){
    if(getResult.isSuccess)
    {
    var ctrlArr = getResult.data;
    alert(ctrlArr.length);
    for(var i = 0; i < ctrlArr.length; i++)
    {
    var subFormCtrlId = ctrlArr[i].getAttribute('id');
    var options = {};
    options.fieldId = subFormCtrlId;
    alert(options.fieldId);  // getting subFormCtrlId  correctly
    options.rowIndex = '*';
    eFormHelper.deleteRowsFromSubForm(options, function(result)
    {

    alert("start delete"); //this is getting executed
    if (result.isSuccess)
    {

    alert("success");//NOT GETTING EXECUTED

    console.log (result.data);
    }
    else
    {

    alert("fail");//getting executed for each item in the loop
    console.log(result.error);
    }
    });
    }
    }
    });

     

    for some reason eFormHelper.deleteRowsFromSubForm is not getting executed,  SubForm1 has 12 iterations of SubForm2 which can have anywhere between 1-10 rows which is what we are trying to delete on button click with this function.

    0
    Comment actions Permalink
  • Avatar
    AgilePoint NX Support

    Hello Madhu,

    We tested the same code in our application and it is working as expected.Please find the screenshot below for reference:

    Screenshot 2:

    Screenshot 3:

    After row deletion:

     

    If any further assistance is required, please raise a support ticket.

    Thanks,

    AgilePoint Support

     

    0
    Comment actions Permalink
  • Avatar
    Madhu

    Thanks so much for the solution.

    Script works for deleting rows from nested subforms.

    Initially it did not work because my click action button and nested subform are in two different sections of the form.

    I moved the button and subforms to the same section and it worked.

    Thanks again for the quick response.

    0
    Comment actions Permalink

Please sign in to leave a comment.