Sonoma Partners Microsoft CRM and Salesforce Blog

Bulkify Bulk Edit

Today's blog post was written by Mike Dearing, Development Principal at Sonoma Partners.

Microsoft Dynamics’ bulk edit functionality is a convenient way to mass update multiple records of the same entity at the same time.

While some additional avenues exist for doing bulk edits, such as native excel imports, or excel online and editable grids for Dynamics 365 Online customers, the bulk edit dialog still provides efficient means for quickly mass updating one or two fields across a filtered set of records. There are a couple of limitations, however, that clients tend to ask about:

How do I blank out values?

There unfortunately isn’t a ‘clear’ keyword like you may be familiar with via workflow functionality. Since every field from the most recently visited main form for the entity currently being edited is available for updating, only those fields which have had values supplied are actually updated once you apply your edit. There are a few workarounds here though:

  1. Create a workflow/plugin that executes when the field you want to clear has had a specific value populated within it. For instance, if you have a text field that you want to clear through a bulk edit, perhaps entering the phrase <Clear> triggers logic that leverages the workflow <Clear> action, a plugin to blank out the value. This approach is pretty limited to specific field types, such as single line of text or multi-line of text fields. For example, if you want to clear out Lead’s Description field when a value of <Clear> is entered, you would configure your workflow as follows:

    1. When description changes

      Bulk 1

    2. Then clear Description

      Bulk 2

    3. If Description's text is <Clear>

      Bulk 3

      If you enter <Clear> into the Description field and press 'Change,' you'll see that each of the selected reords have had their Description value cleared.

  2. Create a ‘Clear X’ field and a workflow/plugin to support it. This could be one additional bitfield per field that you’d like to clear, or an option set that lists out field names that correspond to a list of fields that you want to enable for clearing. Similar to the first approach, you’ll create a workflow/plugin that executes here to do the heavy lifting for you, but this time it will be based on the value within your ‘Clear X’ field. You should also remove the selected value within the ‘Clear X’ field, so that it remains stateless. Once you have this field on the form, it will appear on the bulk edit dialog as well, and users can select it as they’d select any other field within the dialog. You’ll want to hide this field on the main entity form since it doesn’t serve much purpose within a normal edit form, but make sure that it still is available from the bulk edit form. I discuss how to do this later in the ‘How do I control which fields are available for bulk edit?’ part of this post. For example, if you want to clear out Lead’s Description field or Lead’s Industry field, you would do the following:

    1. Create a new ‘Clear Value’ option set.

    2. Add 2 options, one called ‘Description’ and one called ‘Industry’

      Bulk 4

    3. Place ‘Clear Value’ on the lead form

    4. Create your workflow to clear ‘Description’ if Clear Value is set to Description, or to clear ‘Industry’ if Clear Value is set to Industry. Also revert Clear Value back to blank.

      Bulk 5
      Bulk 6
      Bulk 7
      Bulk 8
      Bulk 9

      If you select ‘Description’ for Clear Value and press ‘Change’, you’ll see that each of the selected records have had their Description value cleared. Similarly, if you select ‘Industry’ for Clear Value and press ‘Change’, you’ll see that each of the selected records have had their Industry value cleared.

  3. Create an on demand workflow per field that needs to be cleared. Using the <Clear> action mentioned above, this can be accomplished without much effort. This detracts from the seamless experience of managing all mass edits through the bulk edit dialog, and also doesn’t scale well if there are many fields that you want to enable for bulk clear functionality.

The second option above is the most elegant and flexible if you have the time to implement it. For the first or second option, I prefer plugins over workflows due to the efficiencies of doing these clears in the pre operation pipeline, meaning the changes are written to the database as a part of the same update initiated by the bulk edit, whereas workflows execute post operation, kicking off a second update once the bulk edit’s update has completed. I’ve also considered leveraging dialogs, but their single record execution prevents this from being a viable approach for bulk edits.

How do I control which fields are available for bulk editing?

Rather than there being a ‘bulk edit’ form type, Dynamics leverages the main form type. In the case of multiple main forms, the most recent form that the user has visited will be the basis of their bulk edit form. Even though you can’t edit subgrids and certain other fields, those will still appear on the bulk edit dialog, as well as fields that you conditionally hide via business rules or JavaScript, since neither business rules nor JavaScript execute on bulk edit forms. The suggested approach here is as follows:

  1. To set a field’s visibility such that it doesn’t appear on the bulk edit dialog, hide fields via the main form’s customizations. These fields presumably need to be displayed on the main form still, so define a business rule ‘show’ action per field that should be displayed, or JavaScript to similarly show these fields on load of the main form.

    For example, if you’d like to hide the Website field from Lead’s bulk edit, but still want it to appear on the main form, you would define a business rule as follows:

    Bulk 10


    You would also need to set this field as not visible through the form’s customizations.

    Bulk 11

  2. To set a field’s visibility such that it only appears on the bulk edit dialog, you’ll want to do the opposite of above. Show fields via the main form’s customizations, then define a business rule ‘hide’ action per field that should be hidden, or JavaScript to similarly hide these fields on load of the main form.

    For example, if you’d like to show the field that we created above named ‘Clear Value’ on the bulk edit form, but don’t want it to appear on the main form, you would define a business rule as follows:

    Bulk 12

Since business rules and JavaScript don’t execute on bulk edit forms, the visibility option that you specify for that field through the main form’s customizations will be the visibility of that field on the bulk edit dialog.

With minimal effort, you’ve now enhanced your bulk edit dialogs to be more powerful and more user-friendly. Happy editing!

Topics: Microsoft Dynamics 365