This may not be elegant, but it does what you're asking for.
function actionExists(actionSet, actionName) {
var actionSetExists = false;
var actionExists = false;
var actionSetRef = new ActionReference();
actionSetRef.putName(charIDToTypeID("ASet"), actionSet);
try {
var actionSetDesc = executeActionGet(actionSetRef);
actionSetExists = true;
var actionRef = new ActionReference();
actionRef.putName(charIDToTypeID("Actn"), actionName);
actionRef.putIndex(charIDToTypeID("ASet"), actionSetDesc.getInteger(charIDToTypeID("ItmI")));
try {
executeActionGet(actionRef);
actionExists = true;
} catch (e) {
actionExists = false;
}
} catch (e) {
actionSetExists = false;
}
return { actionSetExists: actionSetExists, actionExists: actionExists };
}
var actionSet = prompt("Enter the name of the Action Set:");
var actionName = prompt("Enter the name of the Action:");
var result = actionExists(actionSet, actionName);
alert('Action Set: ' + actionSet + ' Exists: ' + result.actionSetExists + '\nAction: ' + actionName + ' Exists: ' + result.actionExists);
Thank Microsoft Copilot. 🙂