How to order or set default option for Mass Update select2?

When selecting Mass Update from List View on, for example, Cases, the select2 for the field that is to be mass updated has a certain order.

Can I sort that list and/or at least choose what the default option is?

It seems from massupdate view that I should be able to set the defaultOption in metadata somewhere... but where/how?

thanks,

FrancescaS

Parents
  • Not sure I follow.  Are you saying you want the records updated in a certain order?

  • Hi Francesca Shiekh, sorry to re-use this thread, but do you know if there's a way to have multiple default fields in the Mass Update panel? 

    Regards,

    Rafael

  • Hello Rafael Pedrosa, I have not tried defaulting multiples.

    Perhaps you can look at clients/base/views/massupdate/.

    to see if you can find some clues, it would basically make sense to me that if you could set the fields you want to default as the first ones in your list, then you could render and trigger the "Add Field" action (the + sign on the mass update), to render multiples.

    For what it's worth, here is the code I used to sort the options to have assigned user at the top of my list. By default when I add another field to update using the +, the next item in the list is the one that appears defaulted.

    ({
      extendsFrom: 'MassupdateView',
      initialize: function(options){
        this._super('initialize', [options]);
        var fields = options.meta.panels[0].fields;
            newfields =[],
            option1 = '';
        if (!_.isEmpty(fields)) {
          var i = 0;
          _.each(fields, function(field){
            if(!_.isEmpty(field) && field.name == 'assigned_user_name'){
              //start a new array with assigned_user_name as the first element
              newfields.push(field);
              //remove assigned_user_name from fields
              fields.splice(i, 1)
            }
            i++;
          });
          //add all the other elements to the new list
          options.meta.panels[0].fields = newfields.concat(fields);
        }
      }
    })

    I hope this helps you figure it out, do post your solution when you find it. 

    FrancescaS

Reply
  • Hello Rafael Pedrosa, I have not tried defaulting multiples.

    Perhaps you can look at clients/base/views/massupdate/.

    to see if you can find some clues, it would basically make sense to me that if you could set the fields you want to default as the first ones in your list, then you could render and trigger the "Add Field" action (the + sign on the mass update), to render multiples.

    For what it's worth, here is the code I used to sort the options to have assigned user at the top of my list. By default when I add another field to update using the +, the next item in the list is the one that appears defaulted.

    ({
      extendsFrom: 'MassupdateView',
      initialize: function(options){
        this._super('initialize', [options]);
        var fields = options.meta.panels[0].fields;
            newfields =[],
            option1 = '';
        if (!_.isEmpty(fields)) {
          var i = 0;
          _.each(fields, function(field){
            if(!_.isEmpty(field) && field.name == 'assigned_user_name'){
              //start a new array with assigned_user_name as the first element
              newfields.push(field);
              //remove assigned_user_name from fields
              fields.splice(i, 1)
            }
            i++;
          });
          //add all the other elements to the new list
          options.meta.panels[0].fields = newfields.concat(fields);
        }
      }
    })

    I hope this helps you figure it out, do post your solution when you find it. 

    FrancescaS

Children
No Data