How to delete Quoted line items automatically based on line-item deletion

When I am deleting the lineitem from Group1 and i want to delete the related lineitem automatically from Group2.

Thanks

Kumar

Parents
  • 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

Reply
  • 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

Children
No Data