Hi,
My task is to export the artboard as jpeg based on the Layer color through JavaScript. The task is only export the artboard which is blue in color (hp_airpods_tile and hp_desktop_tile) and other artboards which are in "Red" and "Gray" should not export.

But I am unable to find the layer based on its color. Can anyone help me to resolve this issue?
Please see the below code, which I used for this task.
var doc = activeDocument;
var allLayers = doc.layers;
for (var a = 0; a <allLayers.length; a++) {
doc.activeLayer = allLayers[a];
if (isArtBoard()) {
try {
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), a);
var layerDesc = executeActionGet(ref);
var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
// if not layer group collect values;
if (layerSet != "layerSectionEnd" /*&& layerSet != "layerSectionStart"*/ && isBackground != true) {
var theName = layerDesc.getString(stringIDToTypeID('name'));
var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
var visible = layerDesc.getBoolean(stringIDToTypeID("visible"));
var theColor = layerDesc.getEnumerationValue(stringIDToTypeID("color"));
if (typeIDToStringID(theColor) != "Red" || typeIDToStringID(theColor) != "Gray") {
theLayers.push([theName, theID])
}
else {
theOthers.push([theName, theID])
}
};
}
catch (e) {};
}
}
//Artboard Validation Function
//============================
function isArtBoard() {
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
return executeActionGet(ref).getBoolean(stringIDToTypeID("artboardEnabled"));
}
Thanks
Asuvath