Record the ScriptingListener code for the creation of a B&W Adjustment Layer, then use that and combine it with something like
app.activeDocument.activeLayer.grouped = true
to merge or Clipping Mask it to the underlying Layer.
I can't merge the layer with the Background Layer.
I need to get average of that layer.
Yes! I got it! Thanks!
I would like to convert a layer in to Black and White
so I assumed you want to change just one Layer to black & white.