Forum Discussion

David91's avatar
David91
Frequent Contributor
2 years ago

Load data from persistent variables to Array

Hi, I have a problem. Need with persistent variables where at the beginning of the test I generate data (for the test) insert two variables into an array.. variable is named assortmentName and assortmenCode. But the problem is that in the array is always stored an older value.. for example for the first run of the test the assortmentName is Banana and put into the array.. but when the test is run again so.. in the assortmentName is generated Strawberry but in the array is still Banana because it is stored there since the last run.. is there any way to refresh it in that array? I don't know what to do..


Thanks for any tips. I'm attaching the code from the field..

 

var setAssortment = [

    {

        id: 0,

        erpID: [10],

        name: Project.Variables.assortmentName,

        code: Project.Variables.assortmentCode,

        amount: [10],

        unit: ["KS"],

        optionCode: null,

 

    },

    • David91's avatar
      David91
      Frequent Contributor

      Test running from script. 

       

      I don't think the sent link solves my problem.. there is only an explanation between the variables.. but I understand that. What I don't understand is why you can't draw data from these variables into an array while the test is running

       

      Thank you

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    So you have a variable called setAssortment, and you have properties name and code which you assigned using Project.Variables.assortmentName and Project.Variables.assortmentCode?

     

    If I've set the project variables and then comment out the statement. When I next run the scripts, it's still showing "Banana" and "001", that's because it's using the Local Value.

     

    I'm not sure if the above is a great example, but I think that's the problem you are having with?