I have a script within a portal.
You cannot have a script within a portal.
Maybe you have a BUTTON within a portal; and a script associated with the button?
But what is the script? Can you show it? Can you print the script to PDF or capture it in a screen shot?
Yes, I indicated I had a button but I should have rephrased it better. I'd been playing around with all the known (to me) options to detect the reason for this issue. Included in this search for an answer I have now just moved the button from its location which was immediately at the end of a field in the portal to another location following the next field on the same portal line. Bingo, the script from that button now works on every line. I tested it again and moved it back to its previous location and again it faults on the 4th and 5th lines. There are no other fields in that line, hidden or open to view so while the problem has been solved it doesn't explain why a button activating a script in a portal will work on only some lines.
My immediate issue is solved but no answer is obvious.
Thank you for your response.
The error you're getting probably comes from trying to modify a calculation field by inserting a value into it.
+1 for the Picasso-like description of the problem.