Forum Discussion

venky543's avatar
venky543
New Contributor
7 years ago

Unable to transfer integer value from response to test case level property using setPropertyValue

Hi Guys,   I'm trying to transfer integer value from response to test case level property using setPropertyValue calling from script assertion.   There is a json code in the reponse with value Ba...
  • Lucian's avatar
    7 years ago

    Hey,

     

    Properties are saved as strings so you need to parse the value before trying to save it. Also, I would suggest to use testRunner and not messageExchange (as this is the way it is presented in the documentation and you need no imports for it). So:

     

    testRunner.testCase.setPropertyValue( "FRBasePrice", String.valueOf( SubProducts_0_Price_11_BasePrice ) )

    Let me know if it works! :smileyvery-happy:

  • venky543's avatar
    venky543
    7 years ago

    Hi Lucian,

     

    Thanks a lot.

     

    Actually i'm running the script from script assertion where testRunner will not work. So, had to use messageExchange variable.

     

    it worked for me after i have mentioned "String.valueOf( SubProducts_0_Price_11_BasePrice )" in my script as below.

     

    messageExchange.modelItem.testStep.testCase.setPropertyValue( "FRBasePrice", String.valueOf( SubProducts_0_Price_11_BasePrice ) )

     

    Thank you for your help!!!