Script columns lose access to destination when called from a filter

Script columns can access data from the destination and incorporate it into their calculations.

Quickfilters can use these script columns without triggering a recalculation.

However, the behavior is different for filters:

Accessing a script column from a filter forces a fresh calculation, which will impact processing time.

More critically, when called from a filter, a script column loses access to the destination. This typically causes the calculation to fail or return inconsistent results.

It appears to affect all contexts in which filters can be used.

Some example code would be good :slight_smile:

This column compares the files in the source with those in the destination by name and returns unique or not_unique.

Refreshing the FD:

CompareWithDest:  not_unique	D:\57368\Folders\F1\a.txt	D:\57368\Folders\F2\a.txt
CompareWithDest:  not_unique	D:\57368\Folders\F1\b.txt	D:\57368\Folders\F2\b.txt
CompareWithDest:  unique	    D:\57368\Folders\F1\c.txt	D:\57368\Folders\F2\c.txt
CompareWithDest:  not_unique	D:\57368\Folders\F1\f.txt	D:\57368\Folders\F2\f.txt
CompareWithDest:  unique	    D:\57368\Folders\F1\g.txt	D:\57368\Folders\F2\g.txt

Running the Find Filter:

CompareWithDest:  no tab:	D:\57368\Folders\F1\a.txt
CompareWithDest:  no tab:	D:\57368\Folders\F1\b.txt
CompareWithDest:  no tab:	D:\57368\Folders\F1\c.txt
CompareWithDest:  no tab:	D:\57368\Folders\F1\f.txt
CompareWithDest:  no tab:	D:\57368\Folders\F1\g.txt

(Hey, already the tab is unavailable!)


The script:

DOpus.Output('-----');

var err = 'error';
var nu = 'not_unique';
var u = 'unique';

function OnInit(initData) {
    initData.name = 'CompareWithDest';
    initData.version = '2025-10-03';
    initData.url = 'https://resource.dopus.com/t/script-columns-lose-access-to-destination-when-called-from-a-filter/57368';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddColumns(addColData) {
    var col = addColData.AddColumn();
    col.name = 'CompareWithDest';
    col.method = 'OnColumn';
    // col.justify = 'right';

    col.match.push_back(err);
    col.match.push_back(nu);
    col.match.push_back(u);

    col.namerefresh = true;
    col.autorefresh = 2;
}

function OnColumn(scriptColData) {
    scriptColData.value = err;
    var item = scriptColData.item;

    var tab = scriptColData.tab;
    if (!tab) {
        DOpus.Output('no tab:\t' + item);
        return;
    }

    if (!tab.path) {
        DOpus.Output('no tab.path:\t' + item);
        return;
    }

    var dtab = tab.lister.desttab;

    if (!dtab) {
        DOpus.Output('no dtab:\t' + item);
        return;
    }

    if (!dtab.path) {
        DOpus.Output('no dtab.path:\t' + item);
        return;
    }

    var fsu = DOpus.FSUtil();

    var itemToCheck = dtab.path + '\\' + item.name;

    var ret = fsu.Exists(itemToCheck) ? nu : u;
    DOpus.Output(ret + '\t' + item + '\t' + itemToCheck);

    scriptColData.value = ret;
}

ColumnnCompareWithDest.js.txt

The Button:

XML
<?xml version="1.0"?>
<button backcol="none" display="both" hotkey_label="yes" label_pos="right" textcol="none">
	<label>Set COLUMNS</label>
	<tip>scp:CompareWithDest/CompareWithDest</tip>
	<icon1>#set</icon1>
	<function type="normal">
		<instruction>Set COLUMNSTOGGLE=&quot;scp:CompareWithDest/CompareWithDest(!,a,0)&quot;</instruction>
	</function>
</button>

The Filter:

script match CompareWithDest/CompareWithDest error

The Files:
Folders.rar

Thanks! Fixed in the next update.