How to fetch cancelled opportunity documents

Hello,

I am trying to fetch opportunity documents which are cancelled but I am not getting success. What I come across is even when document is cancelled there status is open. See below

So now how I can get document which are cancelled? What are ways?

Below is my simple client script where i am trying…

frappe.ui.form.on(‘Opportunity’, {
refresh(frm) {
frappe.call({
method: ‘frappe.client.get_list’,
args: {
doctype: ‘Opportunity’,
fields: [‘name’],
filters: {
‘status’: ‘Cancelled’
}
},
callback: function(response) {
if (response.message) {
var cancelledOpportunities = response.message;
console.log(‘Cancelled Opportunities:’, cancelledOpportunities);
} else {
console.log(‘No cancelled Opportunities found.’);
}
}
});
}
});

Hi @pm23,

Please check the syntax and apply it according to the scenario.

frappe.ui.form.on('Opportunity', {
    refresh(frm) {
        frappe.db.get_list('Opportunity', {
            filters: { 'docstatus': 2},
            fields: ['name'],
            limit: null
        }).then(oppo => {
            oppo.forEach(val => {
                console.log("---------", val)
            });
        });
    }
});

Thank You!

@NCP ,

Its working.

Thanks!!