Beanshell script to handle Correlation Value "Not Found" equal to "ERROR" in Jmeter

 In Loadrunner we have an attribute in the correlation function which will fail the request/user if the correlation value "Not Found" is set to ERROR. But in the Jmeter we do not have any such straight forward approach and the same can be achieved using the below code in the Beanshell assertion. 

C_SAMLC_RelayState are the two correlations that has been done in a request and below code will check if they are null (Empty) and if that is true, it will fail the request.

Code to the Placed in Beanshell Assertion:

String SAML = vars.get("C_SAML"); //Save the correlation value to a string
String RelayState = vars.get("C_RelayState"); //Save the correlation value to a string
if (C_SAML != null && C_RelayState != null) //if condition to check if the value is not null
{
Failure = false; //if the value is null fail the sampler or request
}
else
{
Failure = true; //if the value is not null pass the sampler or request
}

Note: Make Sure to leave the Default value field as empty in the Boundary or RegEx extractor while using the above validation approach.