Delete rows from nested subform using eFormHelper.deleteRowsFromSubForm
I am able to delete rows in a subform using below code.
var options = {};
options.fieldId = 'SubForm1';
options.rowIndex = '*';
eFormHelper.deleteRowsFromSubForm(options, function(result)
{
if (result.isSuccess)
{
console.log (result.data);
}
else
{
console.log(result.error); //Logs the error and error description, if any.
}
});
I am trying to use below to delete rows from nested subform
var options = {};
options.fieldId = 'SubForm1/SubForm2';
options.rowIndex = '*';
eFormHelper.deleteRowsFromSubForm(options, function(result)
{
if (result.isSuccess)
{
console.log (result.data);
}
else
{
console.log(result.error);
}
});
this does not work. Any idea what I am missing to delete rows from nested subform.
Thanks
-
正式评论
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
评论操作 -
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.
-
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.
请先登录再写评论。




评论
4 条评论