Skip to content

Instantly share code, notes, and snippets.

@anil826
Last active July 30, 2020 11:37
Show Gist options
  • Save anil826/5f8a397be4eb88d2f8b3b9dc3c578f1c to your computer and use it in GitHub Desktop.
Save anil826/5f8a397be4eb88d2f8b3b9dc3c578f1c to your computer and use it in GitHub Desktop.
Updated Javascript for delete button functionality
//On repeate update
var total_prefilled_records;
formyoula.form_fields["8ba9-776a-b85e"].on('input:set:success', function (e) {
//Get total record
total_prefilled_records = formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value').length;
for (var i=0; i<total_prefilled_records ; i++) {
if ( formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[i][1].value ) {
$('a[data-item_index="'+i+'"]').hide();
}
}
});
//On Repeate add
formyoula.form_fields["8ba9-776a-b85e"].on('element:create:success', function (e) {
for (var i=0; i<total_prefilled_records ; i++) {
if ( formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[i][1].value ) {
$('a[data-item_index="'+i+'"]').hide();
}
}
});
//On repeate delete
formyoula.form_fields["8ba9-776a-b85e"].on('element:delete:success', function (e) {
total_prefilled_records = formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value').length-1;
for (var i=0; i<total_prefilled_records ; i++) {
if ( formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[i][1].value ) {
$('a[data-item_index="'+i+'"]').hide();
}
}
formyoula.form_fields["8ba9-776a-b85e"].get("repeat_value").forEach(function(repeat_item, index) {
increment_counter++;
var href = "#collapse_" +repeat_group_component_id +"_"+index;
var updated_prod = _.where(formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[index], {'component_id': '1694-956f-5233'});
var updated_prod_value = updated_prod[0]['value'];
var updated_quan = _.where(formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[index], {'component_id': '582b-2d94-d8c8'});
var updated_quan_value = updated_quan[0]['value'];
var updated_sup_ui = _.where(formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[index], {'component_id': 'e7d2-43f0-d2cc'});
var UI_text = $($(updated_sup_ui[0].name)[0]).find('.sfdc_field_Name').text();
var updated_sup = _.where(formyoula.form_fields["8ba9-776a-b85e"].get('repeat_value')[index], {'component_id': '5f4c-2f80-11f3'});
var updated_sup_value = updated_sup[0]['value'];
$('div[href="'+ href +'"] > h4 >a').text(updated_prod_value + " | Quantity: "+ updated_quan_value + " | Supplier: " + (UI_text ? UI_text : updated_sup_value ));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment