Newman does use current variable value

Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

I have a request which inserts some data and the ID should be incremented every time by +1. The request is working fine in Postman runner, but not in Newman where is fails after 1st execution.

PRE-REQUEST SCRIPT - Get the variable value and increate is by 1

let x = pm.environment.get(“SystemSettingTypeIncrementer”);
pm.environment.set(“SystemSettingTypeIncrementer”, Number(x) + 1);

TEST SCRIPT - Set the variable value with new value

pm.environment.set(“SystemSettingTypeIncrementer”, jsonData.Type);
console.log(“SystemSettingTypeIncrementer is set to:”, jsonData.Type);

Fails with what error?

Are you including your environment file in the Newman command line?

If you’ve already set and increased the variable in the pre-change test script, why do you need to do it again in the test script?

What is SystemSettingTypeIncrementer? A JSON object or a number? It looks like you are mixing data types.