@gayatrik8153299
We have 2 options.
1. If this autogenerated tabcount need to be secured then add below mentioned afteredit listener in cq:listeners of component & whenever component is updated this generateTabCount() function will be triggered, you can write ajax request call to servlet in this method & in servlet you can iterate multifield resource node & using ModifiableValueMap you can add this tabcount if its not generated/exist.
<cq:listeners
jcr:primaryType="cq:EditListenersConfig"
afterdelete="function(){generateTabCount()}"
afterinsert="REFRESH_PAGE"
aftermove="REFRESH_SELF"/>
2. If this autogenerated tabcount can be exposed to client side/less secured, then you can create additional field in multifield as mentioned below with hidden class name so it will be hidden, write author clientlib listener & on dialog submit generate tabcount & assign values to these hidden tabcount dialog fields.
<tabCount
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
granite:class="unique-tab-count hidden"
name="./tabCount"/>
listener js
(function ($, $document) {
"use strict";
$(document).on("click", ".cq-dialog-submit", function (e) {
$('.unique-tab-count').each(function(index){
var tabCount = $(this).val();
if(!tabCount){ //if tab count not generated previously
tabCount = 'unique-id';// generate & assign unique id here
$(this).val(tabCount);
}
});
});
})($, $(document));
-Manjunath