When I am deleting the lineitem from Group1 and i want to delete the related lineitem automatically from Group2.
Thanks
Kumar
I do this by extending ProductBundlesQuoteDataGroupListView:
custom/modules/ProductBundles/clients/base/views/quote-data-group-list/quote-data-group-list.js
I use an API to get the relatedServiceItems, the API will just return the ids of the product lines to be removed, it should be fairly simple for you to find the lines related to the quote that have the same part number.
({
extendsFrom: 'ProductBundlesQuoteDataGroupListView',
initialize: function(options){
this._super('initialize' ,[options]);
},
//NB overrides original
_onDeleteRowBtnClicked: function(evt) {
var row = this.isolateRowParams(evt);
if (!row.id || !row.module) {
return false;
}
app.alert.show('confirm_delete', {
level: 'confirmation',
title: app.lang.get('LBL_ALERT_TITLE_WARNING') + ':',
messages: [app.lang.get('LBL_ALERT_CONFIRM_DELETE')],
onConfirm: _.bind(function() {
app.alert.show('deleting_line_item', {
level: 'info',
messages: [app.lang.get('LBL_ALERT_DELETING_ITEM', 'ProductBundles')]
});
this.deleteServiceItems(this.collection.get(row.id));
this._onDeleteRowModelFromList(this.collection.get(row.id));
}, this)
});
},
deleteServiceItems: function(deletedRowModel){
var self = this,
productID = deletedRowModel.get('id'),
url = app.api.buildURL('Products/relatedServiceItems/'+productID);
app.alert.show('check_service',{
level: 'process',
title: 'Checking for related Service Item/s...',
});
app.api.call('GET', url, null,{
success: function(related){
if(!_.isEmpty(related)){
_.each(related, function(serviceItem){
self._onDeleteRowModelFromList(self.collection.get(serviceItem['id']));
app.alert.dismiss('check_service');
});
}else{
app.alert.dismiss('check_service');
}
},
error: function(e){
console.log(e);
app.alert.dismiss('check_service');
},
});
},
})
FrancescaS
Thanks Francesca Shiekh for your reply. I will try this. But this will work for existing items. I want delete the new items from create view which are not saved yet.
Sorry Sundar Kumar, you are right, mine is a special scenario. I force my users to save the quote before adding items and because I create the service item when the product line item is saved, both rows are saved and linked to the quote.
I did same way but i am getting deleteRowModel is undefined error in _onDeleteRowModelFromList function, while deleting line item in record view.
Looks like service items collection is coming undefined. Did you face the same issue?
I do not recall seeing that issue, it's been a few years since I did this and it has been working well.