Is it possible to modify a variable in Postman
<p>I'm using Postman and I am trying to chain together some requests. There is an identity string that is generated in my first request that I would like to use in my second request e.g. similar to searching for a product, and then adding that product to basket.</p>

<p>Now I've been able to pull the value from the first request and I can pick that up in the second request. The problem is that the identity string has an ampersand in it. When I post the second request, it throws an error because the ampersand has not been escaped in the string. I would like to replace the ampersand in the variable with "&amp;" but I can't get this to work.</p>

<p>I'm new to JavaScript so I imagine this is where the problem is. In Postman I have:</p>

<p><code>var jsonObject = xml2Json(responseBody);
console.log(jsonObject);
postman.setEnvironmentVariable("ItineraryId", jsonObject.ItineraryId);
ItineraryId.replace("&amp;","&amp;amp;");</code></p>

<p>This returns "There was an error in evaluating the test script:  ItineraryId is not defined". So I tried:</p>

<p><code>var jsonObject = xml2Json(responseBody);
console.log(jsonObject);
var oldId = postman.setEnvironmentVariable("ItineraryId", jsonObject.ItineraryId);
oldId.replace("&amp;","&amp;amp;");</code></p>

<p>And got "There was an error in evaluating the test script:  Cannot read property 'replace' of undefined"</p>

<p>Thanks in advance.</p>