Sequential numbering for dataset entries

I need to have a sequential ID assigned to each new entry in a dataset. The ID number needs to work with the client’s internal system, so the ID assigned by the system isn’t the right solution.

The content is user-generated and an automatic solution is required.

I’ve added the following code, but it is not working.

During test mode, I’ve hand-entered a petID. You can see in the pic below that after the code above was input and published, a new item appears in the dataset, but has neither a petID or a newID. I don’t know if the hand-entered IDs are an issue? Or that the resulting field is marked as ‘primary’?

Help! :slight_smile: