Hi,
My form includes a table with intial count of 10 rows. Its a static form. Sometimes users may fill only 2 or 3 rows. And if they submit, I see the dataxml contain all the 10 records with 2 filled records and 8 null records.
How can I delete these null instances from the data xml in the pre-submit event? I checked some of the posts where it says how to delete a node. But, I want to delete only those instances which have no values.
My xml always display something like this:
<POrder>
<BudgetAlloc>
<itemno>001</itemno>
<itemname>item1</itemname>
</BudgetAlloc>
<BudgetAlloc>
<itemno>002</itemno>
<itemname>item2</itemname>
</BudgetAlloc>
<BudgetAlloc>
<itemno/>
<itemname/>
</BudgetAlloc>
<BudgetAlloc>
<itemno/>
<itemname/>
</BudgetAlloc>
</POrder>
Here I want to delete the last 2 nodes with null values. This is a pressing issue for me. Please help.
Thanks
kc
Views
Replies
Total Likes
Hi,
Which type of dataconnection are you using? Is it sample XML or XML schema? OR You just want to delete those nodes which has no values (without using any dataconnection as xml)?
Thanks,
Bibhu.
Views
Replies
Total Likes
Hi bibhu,
I'm using XML schema. And the fields are binded to it.
I dont want to delete the nodes but only the data instances for null values for that node. Node is of repeating record.
kc
Views
Replies
Total Likes
Hi,
Are you using any XSLT transformation to transform the out-going data of the form? If not, then I guess you have the only choice left to remove the nodes. Because as long as there is databinding all the nodes would be exported.
Thanks,
Bibhu.
Views
Replies
Total Likes
Bibhu,
I'm not using any XSLT.
In the pre-submit event, I can able to find the nodes that have null data.
//retrieve the list of instances with null values for txtUnitName
var list = xfa.resolveNodes('$record.BudgetAllocationSection.BudgetAllocationUnit.[txtUnitName == null]') ;
and app.alert(list.length) gives me the count of nodes.But not getting the proper syntax to delete all these nodes.
If we can able to delete a node, I think there should be a way to delete only certain instances of that repeating node.
--kc
Views
Replies
Total Likes
Hi,
Try to find out the node index which has null value. If you can find out the node index then you can delete the particular node. Use a loop to loop through all the nodes, then check whether any of the node has null value. Try to findout the index then delete that particular node. Currently I am also unable to recollect the proper syntax of finding the index of a node.
The syntax to remove all nodes of a particular attribute is : $record.nodes.remove($record.BudgetAllocation).
Thanks,
Bibhu.
Views
Replies
Total Likes
Hi,
I just tried with this code.
list = xfa.resolveNodes('$record.BudgetAllocationSection.BudgetAllocationUnit.[txtUnitName == null]');
for (var i = 0; i < list.length; i++)
{
xfa.resolveNodes('$record.BudgetAllocationSection.BudgetAllocationUnit.[txtUnitName == null]').remove(list.item(i));
}
It's not resulting any errors. If i put the list in a string and check, I see its deleting the nodes in the string variable. But some how it's not reflecting in the dataxml when I click on submit.
Is there anything wrong with this code?
kc
Views
Replies
Total Likes
Hi,
I am bit confused about the XML you are emebdding and the XML you are getting as a result of submission. Does it export the same XML you are embedding after submitting the form? If yes, then you have to get rid off the databinding and have to do a bit of scripting to access the values. As long as there is data binding all the nodes would be exported.
Thanks,
Bibhu.
Views
Replies
Total Likes
Hello Bibhu,
sorry for the delayed response. Yes, I'm using the same xml for import & export. The fields are binded to the subform fields. Subform is a repeating instance
so, I dont think deleting certain instances will impact the binding as I want to keep atleast one instance and remove only the blank ones.
Can someone look into my code and help me on this?
Would be a great help.
k.c
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies