Unable to get layer bounds and selection bounds

HI previously i was using the same function but now i am unable to get the layer bound with following code

Blockquote
async function getBounds() {
await core.executeAsModal(async () => {
const waj = await batchPlay(
[
{
_obj: “get”,
_target: [
{
_property: “bounds”
},
{
_ref: “layer”,
_enum: “ordinal”,
_value: “targetEnum”
}
],
_options: {

				}
			}
		], {
		synchronousExecution: false,
		modalBehavior: "fail"
	});
	const pinned = waj[0];
}, {})

}

this is the error. “The command failed because Photoshop is in a modal state”. No other function is running

same way selection bound is also not working

It is because of modalBehavior is set to fail

modalBehavior: "fail"

Try making this change

modalBehavior: "execute"

Also, you can probably just change this

{
		synchronousExecution: false,
		modalBehavior: "fail"
	}

to this

{}

and just let it run default… assuming you are running API 2 it will default to execute.

thankyou .it worked.