This is why I suggested the approach that I did originally. You cannot rely on anything associated with a post because that post can be deleted. The only way to do this without errors is to have some consistent value that cannot be removed.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users