Programmatically replace old slice with new slice across ≈200 documents?

Hey, Prismic team! I'm trying to replace one of our worst legacy slices (used in ≈200 documents) with one of our newer slices, built using Slice Machine.

The legacy slice is used to present the exact same content to ≈200 pages, but the content is managed individually on each page—meaning that if someone wanted to update the content, they'd need to do so on ≈200 individual pages.

The new slice we've built out in Slice Machine uses a content relationship so that presentation is controlled through the slice but the content is managed from a single "reference document."

Is there any way for me to programmatically remove the slice from the ≈200 documents and replace it with the new slice (ideally, including the link to the reference document) so that content creators don't have to manually update each document? We already know how to programmatically find each document using the legacy slice, but we're not sure whether we can programmatically edit/update those documents (removing old slice, adding new slice).

Would Prismic's import/export functionality be an advisable means of doing this?

1 Like

Thanks for sharing your use case @dan.duett. We've had a couple of similar posts about this here in the forum:

Hey @dan.duett - I've had this issue in the past several times and the fastest/safest option is to do it manually by either asking the intern in the marketing team or outsourcing.