I am having issue on __setProperty function when used in if condition.

I initialised (API_PASS_YN ) to 'Y' in thread group1 and using it across thread groups.

And in Thread group2 i am setting it to 'N' based on a condition which is response code,Problem is that even if responsecode is 200,it is executing line in "else" (${__setProperty(API_PASS_YN, 'N')} and on BSF exit it is holding 'N' value which is not right.Response code is returned correctly as 200.

Is this right approach or not?Any help is appreciated.

Below is the script structure

==Thread Group 1(Initialize the property to Y )
====BSF Sampler (Initialize the property to Y )

code in BSF //Javascript

OUT.println ("Initializing API_PASS_YN");

${__setProperty(API_PASS_YN, 'Y')};

OUT.println ("API_PASS_YN set to: "+"${__P(API_PASS_YN)}");

==Thread Group2
===Http Request
======BSF Assertion //Using Javascript language

//Getting Response code of a Http request

var statusMessage = SampleResult.getResponseCode();
OUT.println ("StatusMessage bsf assertion upon entering: "+ statusMessage); //returns 200
OUT.println ("API_PASS_YN upon entering HTTP REQUEST bsf assertion: "+ ${__P(API_PASS_YN)});//returns Y

if (statusMessage == 200) //response code is 200
OUT.println ("API_PASS_YN upon successful HTTP REQUEST bsf assertion: "+ ${__P(API_PASS_YN)}); //returns Y
${__setProperty(API_PASS_YN, 'N')};
OUT.println ("API_PASS_YN upon Bad HTTP REQUEST bsf assertion: "+ ${__P(API_PASS_YN)});

OUT.println ("StatusMessage bsf assertion upon exit: "+ statusMessage); //returns 200
OUT.println ("API_PASS_YN on exit of bsf assertion: "+ ${__P(API_PASS_YN)});//returns N which is not right,it should be Y