Answered question

How to modify all occurrence of the extracted variable?

From a webpage response, we are extracting all occurrences of the data.
example: {id:1,ref:001},{id:2,ref:002},{id:3,ref:003}

Now, we have to post the all occurrences but modified (+A) as below :
{id:1,ref:A001},{id:2,ref:A002},{id:3,ref:A003}

How to modify all occurrence of the extracted variable?

Eric N.
Eric N.

Eric N.

Level
0
80 / 100
points
Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

Another way to do that is to split the value and join it again with that function:

function decode(encodedValue) {
    var decodedValue = encodedValue.split("ref:").join("ref:A");
    //Apply decoding logic here.
    //JS Libraries can be used
    return decodedValue;
   
    }

Did you find this useful ?

No (0)

Yes (0)

0% of users found this answer useful

Other answers

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

In the variable extractor panel you have an option called "Value is encoded". If you choose the custom item in the drop down list you can edit a Javascript in order to modify your extracted value on the fly.

I guess in your case you can use a replace method to automatically replace all your ref: by ref:A strings.

Example:

function decode(encodedValue) {
    var decodedValue = encodedValue.replace(/ref:/g, "ref:A");
    //Apply decoding logic here.
    //JS Libraries can be used
    return decodedValue;
}