My searching for this only displayed a solution which wasn't relevant: Process Builder and Test Classes

Use Case:

  1. We have a process that creates a chatter post on user record insert OR profile edit.

  2. There is an apex test class that inserts a user (testuser) to run tests for totally separate reasons.

The problem:

We ran into migration errors (changeset didn't validate) because the process wasn't able to effectively run. The error we received from the process was "failed to create record (FeedItem), source record (User) was deleted."

After some investigation, we found that the apex class was creating a user, "testuser" and the process was then running and aiming to create a chatter post, however user was already deleted (due to being an apex test), and the FeedItem couldn't be loaded.

  • We tried modifying the process to exclude any users named "testuser," which didn't work because the user record was already deleted (in retrospect, duh).

  • Understood that we can disable the process, migrate, re-enable process, as well as deploying via metadata API. However, we're looking for a fix instead of a bandaid.

Anyone come across this/have any solutions for the specific use case?


  • If you run this test in your Sandbox do you get this issue, or is it only happening on deployment? – dBeltowski Feb 23 '16 at 16:50
  • Adrian - Edited to add the wrong answer above. – WHKV Feb 23 '16 at 16:52
  • Doug - this errors on tests and deployment within a sandbox - haven't tried in prod. – WHKV Feb 23 '16 at 16:53
  • sounds like the Process is working with hard-coded users; – cropredy Mar 1 '16 at 6:22
  • @crop1645 - do you have a link to any documentation? Are you saying issue is avoided with a hard-coded user, or that the process I documented above has hard coded the user? As a test class automatically generates and deletes (my assumption) a user before the process runs (order of execution), I wasn't aware of a way to persist any of the data for the process to run off of. – WHKV Mar 1 '16 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.