Nextgen TextOutputCallback is not displaying message

am using below script and its not displaying the value in textoutputcallback with nextgen. Legacy script is working as expected.

if (callbacks.isEmpty()) {
callbacksBuilder.TextOutputCallback(
2,
sharedState )
action.goTo(‘true’);
} else {
action.goTo(‘true’);
}

what is equivalent of below in next gen script

var fr = JavaImporter(

org.forgerock.openam.auth.node.api.Action,  

   javax.security.auth.callback.TextOutputCallback  

)

if (callbacks.isEmpty()) {

action = fr.Action.send(  

       new fr.TextOutputCallback(  

           fr.TextOutputCallback.ERROR,  

           sharedState  

    )  

).build()  

} else {

         action = fr.Action.goTo("true").build()  

}

Hey.

I believe there is a small typo in your code while calling Text Output Callback

callbacksBuilder.textOutputCallback(2,"message")

Additionally, sharedState is not available in next gen engine. You may have to get the value you require from nodeState using nodeState.get(<<key>>).