Manuals for parts still in production are still available on manufaturer websites, so a url is shown. When the file is no longer available, an archived copy can be downloaded.
I needed a way to determine which link to use and format the output accordingly. I would love to have a way to automatically check the url and see if it's still hosting the pdf, but that is too complicated for now. I will just add a boolean field as a flag.
To format the output, I created a view, thinking I could use the part id or manual reference field values as views arguments. Then I could use layout builder on documents to display this view. I got the output working by rewriting the results of the source url to show the document download link if the boolean field is checked. But this didn't work because there wasn't a way to get the field values as arguments.
Views Field Formatter does exactly this. You can create a view and use it to format a field, choosing the entity ID or field values as an argument. I built the view to use field values, so it would work with different entity types.
I also tried Custom Formatters, but that module doesn't seem to be working in Drupal 10.
There are some other text field formatters that could have worked with tokens