getting api before save to run when doing mass update.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 273

    #1

    getting api before save to run when doing mass update.

    its quite important that my users can't find an easy way around the validation rules and not having them run before mass update is a major hole that they will exploite so quickly its hardly worth me making any validation at all

    so how do i get the validation to run before mass update?
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9765

    #2
    Mass update does not apply API before save script. It applies field level validations and assignment permission checks. For such cases, there are a few options:
    • Forbid mass update for users (in Roles).
    • Forbid mass update for particular fields (in metadata > entityDefs > fields).
    • Disable mass update for a particular entity type (in metadata > recordDefs).
    • Add an ORM-level before save hook that will do validation again and throw an error.

    Comment

    • yuri
      EspoCRM product developer
      • Mar 2014
      • 9765

      #3
      I think, we will need to expose field-level "massUpdateDisabled" parameter in the Entity Manager in future.

      How PHPStorm shows documentation for metadata parameters:

      Click image for larger version

Name:	image.png
Views:	0
Size:	36.8 KB
ID:	125649

      Comment

      • jamie
        Senior Member
        • Aug 2025
        • 273

        #4
        so there is no way to get validation rules to apply to mass updates? That is really what is needed

        Comment

      • jamie
        Senior Member
        • Aug 2025
        • 273

        #5
        rabii but then why does yuri say it doesn't?

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1391

          #6
          jamie

          Yuri said this
          PHP Code:
          Mass update does not apply API before save script
          which is true and what i said is that based on code i have checked massupdate action does go through the validation process as i shared with code above unless if i am missing something. in all case Yuri is the lead developer he knows espocrm better than anyone so you should always take his words as source of truth

          I have tested this - so in the Account the name field has pattern $noBadCharacters and when you try to mass update the name of the accounts using something that trigger this pattern it will through a validation error - see below screenshot - meaning you just need to tighten your validation for fields and users won't be able to skip this in massupdate

          Click image for larger version

Name:	account-mass-update.png
Views:	0
Size:	40.0 KB
ID:	125668
          Rabii
          EspoCRM Custom Development

          🔗 Portfolio & Builds

          Comment

          Working...