Bulk edit not working on most of the fields, how to solve

default discord avatar
mvdve
3 months ago
6

Hi All, when using the bulk edit feature in de admin ui, i am running in to an issue: On almost all fields the update fails with the message "Unable to update 1 out of 1 collection-name". There is no other message and there are no errors within the console.



What is the proper way to debug this, or is there some kind of limitation on bulk updates?



Would appreciate it if someone has a suggestion on this issue. Bit stuck on this one.

  • discord user avatar
    jesschow
    Payload Team
    3 months ago

    Hi @mvdve, if you open the Network tab in your browser and try to make a bulk update, do you see a failed request?



    Another thought, on the collection you are trying to update, do you have update access set to true?


    access: {
      update: () => true,
    }
  • default discord avatar
    mvdve
    3 months ago

    Hi @jesschow thanks for the tips! Update is not set to true, that would be a bit of a security issue, i tested this but made no difference. I do see an error message in the json response of the failed request. The slug field should be invalid which is strange, because i can for example bulk edit the title, but not a category and editing this page via the normal way is always successful.



    Found it: When doing a bulk update, only that field is set. In my case, there is a validation hook on the slug which throws an error because the value is undefined, even when the field is required.

  • discord user avatar
    jesschow
    Payload Team
    3 months ago

    Aaaah I see! Nice catch!

  • default discord avatar
    mvdve
    3 months ago

    For future reference: the types within the hooks are correct. They are for example string | undefined for the field hook and string[] | Category[] for a collection hook. The behavior between a single update and bulk update is different: With a single update, only the id's of a relationship are set and with a bulk update the full related collection item is returned so you have to do a bit of type checking when creating hooks. Something to keep in mind.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.