Help with formatting own style

Please help, formatting experts!

Trying to get short form citations to work…

The following command works fine:

(Author|, Year|, Cited Pages|)

With this, whenever the “cited pages” field is empty, the “Year” will be followed immediately by the final closing bracket

However, the following does not work the same way:

Author|, Year|, Cited Pages|.

All I have done is remove the ( ) and use a full stop at the end. Yet now, when the “cited pages” field is empty, I get a comma and a space before the final punctuation!

Why is it behaving like this?

thanks for your help