Hi @Laura,
Try changing the $featureset to just $feature and see how that works.
What you could do is take the highest value in the list and then add the object id to create the unique number and then convert that to text and add 'P' at the beginning.
Unfortunately, alpha-numeric ids are really difficult to work with because of the fluctuations in values.
The code snippet above does work, but it would mostly work with attribute rules.
If you truly need something akin to that, then my only other suggestion would be to create an attribute rule, similar to how the field calculation is set up, and then try running a nonchalant calculation to trigger the rule.