You need to create a new color plate "colorA" first.
.I got it right when I set it up manually, but this script doesn't work, I think the code for creating a new color plate doesn't work.
//make a character style then set its properties
var cs = makeCharStyle(app.activeDocument, "columnAchaStn", "colorA")
cs.properties = { fillColor: "colorA", fillTint: 50 }
/**
* If it does't exist, makes a new named CharaterStyle
* @ param the document to add the style to
* @ param style name
* @ return the named character style
*/
function makeCharStyle(d, n, c) {
if (d.characterStyles.itemByName(n).isValid) {
return d.characterStyles.itemByName(n);
} else {
return d.characterStyles.add({ name: n });
}
var myColorToCheck = app.activeDocument.colors.itemByName(c);
if (!myColorToCheck.isValid) { app.activeDocument.colors.add({ colorValue: [0, 100, 0, 0], name: c }); };
}
There’s also this clever generic collection function suggested by @brian_p_dts here:
https://community.adobe.com/t5/indesign-discussions/how-to-create-various-styles-with-scripts/m-p/15344854#M626385
//https://community.adobe.com/t5/indesign-discussions/how-to-create-various-styles-with-scripts/m-p/15344854#M626385
//generic collection maker document, name, collection
var c = makeStyle(app.activeDocument, "colorA", "colors");
c.properties = {space:ColorSpace.CMYK, colorValue:[0,10,0,0]};
var cs = makeStyle(app.activeDocument, "columnAchaStn", "characterStyles")
cs.properties = {fillColor:"colorA"}
/**
* Make a new collection
* @ param the document
* @ param the name
* @ param the collection class
* @ return the named collection
*/
function makeStyle(d, n, collection) {
if (d[collection].itemByName(n).isValid) {
return d[collection].itemByName(n);
} else {
return d[collection].add({name:n})
}
}