Skip to main content
_wckdTall_
Inspiring
Jul 9, 2026 5:58 PM UTC
Question

Get app.findColorPreferences.findWhat property value

I’m looking for a way to read the value app.findColorPreferences.findWhat, and find out what swatch it’s currently looking for. It gives the error 30615 The property is not applicable in the current state.

I am able to set it:

app.findColorPreferences.findWhat = app.activeDocument.swatches.item("SWATCH_NAME")


Is there a way to read what swatch is currently selected in the dialog, similar to findGrepPreferences and findTextPreferences?

    5 replies

    nik.m
    Community Manager
    Community Manager
    Jul 22, 2026 9:28 PM UTC

    Hi ​@_wckdTall_, just checking in to see if the suggestions from our Experts helped, or if you still need help.

    If yes, please let us know and we'll be happy to assist further.

    Thanks,
    Nikunj

    Translate
    Community Expert
    Jul 9, 2026 6:45 PM UTC

    You can read the Find Colour setting like this:

    var currentFindColor = app.findColorPreferences.findWhat;

    if (currentFindColor === NothingEnum.NOTHING) {
    alert("No Find Color swatch is set.");
    } else if (currentFindColor && currentFindColor.isValid) {
    alert("Current Find Color swatch: " + currentFindColor.name);
    }

    But this is reading InDesign’s Find/Change preference, not the open Find Colour dialog itself.

    Could be best to remember the swatch yourself when you set it:

    var swatch = app.activeDocument.swatches.itemByName("SWATCH_NAME");

    app.findColorPreferences.findWhat = swatch;

    // remember what your script set
    var currentFindColorSwatchName = swatch.name;

    That way, your script is not relying on checking the dialog later. It already knows what value it assigned.

     

    And maybe clear the Find/Change preferences when finished

    app.findColorPreferences = NothingEnum.NOTHING;

     

    Translate
    _wckdTall_
    Inspiring
    Jul 14, 2026 6:12 PM UTC

    Thanks! That’s what I was seeing as well, that app.findColorPreferences.findWhat produces an error and cannot be read.

     

    Translate
    rob day
    Community Expert
    Community Expert
    Jul 15, 2026 12:51 AM UTC

    Hi ​@_wckdTall_ , findWhat expects a swatch, so here swatches.itemByName() works

     

    alert(colorSearch(doc, "Blue"))
    //returns 3

    function colorSearch(d, fc){
    //clear F&C
    app.findColorPreferences = app.changeColorPreferences = app.findChangeColorOptions = null;
    app.findColorPreferences.findWhat = d.swatches.itemByName(fc);
    alert(d.swatches.itemByName(fc).name)
    //returns Blue
    app.findColorPreferences.tint = 100;
    //findColor returns a number
    return app.activeDocument.findColor()
    }

     

    Translate