Suspension of the history state

Suspension of the history state.
Does anyone know how to make it work using await app.batchPlay?

I tried using the sample page method but it doesn’t work even in the latest version of Photoshop.

Please share the code and exactly what doesn’t work. You must use executeAsModal()

Since I’m not a developer and I’m just starting out, I’m probably making serious mistakes.
Here’s the code with a simple effect on the image.

document.getElementById('btnOutono').addEventListener('click', async () => {
		await core.executeAsModal(async () => {	
			let hostControl = executionContext.hostControl;
			let documentID = await getTargetDocument();
			let suspensionID = await hostControl.suspendHistory({
				"documentID": documentID,
				"name": "Custom Command"
			});
		
		await app.batchPlay([{"_obj":"make","_target":[{"_ref":"adjustmentLayer"}],"using":{"_obj":"adjustmentLayer","color":{"_enum":"color","_value":"violet"},"name":"Outono","type":{"_obj":"selectiveColor","presetKind":{"_enum":"presetKindType","_value":"presetKindDefault"}}}},
		{"_obj":"set","_target":[{"_enum":"ordinal","_ref":"adjustmentLayer","_value":"targetEnum"}],"to":{"_obj":"selectiveColor","colorCorrection":[{"_obj":"colorCorrection","black":{"_unit":"percentUnit","_value":40.0},"colors":{"_enum":"colors","_value":"yellows"},"cyan":{"_unit":"percentUnit","_value":-75.0},"magenta":{"_unit":"percentUnit","_value":15.0},"yellowColor":{"_unit":"percentUnit","_value":50.0}}],"presetKind":{"_enum":"presetKindType","_value":"presetKindCustom"}}}], {});			
		})
		await hostControl.resumeHistory(suspensionID);
	});

If you check the docs, first param of the target function is execution context. With your code, if you check console output, you should see an error, that executionContext is undefined. Try adding it to your function:

		await core.executeAsModal(async (executionContext) => {	

Also, you probably don’t have the getTargetDocument function. I assume you just copied code from the example. Almost none of the example code in the docs will work without adapting to your code.

Try instead of:

			let documentID = await getTargetDocument();

this:

			let documentID = app.activeDocument.id;

And always check Console for errors

First of all, I have no words to express my gratitude due to the importance of this subject for my case. I mean now you have a #1 fan Karmalakas. You gave me the attention that, honestly, I didn’t even imagine lol Thank you very much. Problem solved! Here’s a video of the result.