Dispatch Help - Right click command ONLY available during specific transitions/states

I'm trying to edit a script of mine that renames file. I don't want it to be always available.

Is it possible to only show the right click context menu when files are in specific state?

If not is it possible to only run on files in specific states? ie its always available as right click, but will just give error message unless the conditions of states are met

Thanks guys

SolidworksSolidworks Pdm enterprise Pdm