use collection variable postman code example
Example 1: postman environment variables
pm.environment.set("variable_key", "variable_value");
Example 2: defining collection variables
Use pm.collectionVariables to define a collection variable:
pm.collectionVariables.set("variable_key", "variable_value");