PDM Dispatch for Pulling new Serial Number

Hello,

I am currently using SolidWorks PDM Professional 2021 SP5. I would like to write a PDM Dispatch script that will pull the next PDM Serial Number available and write it to a variable field in my data card. Then i would like for it to rename the file with this new Serial number. I am having trouble with the script action for pulling the new Serial number and writing it to the data card.

Any help would be great. Thank you.