async function get_workflow_transitions(frm) {
console.log('Getting get_workflow_transitions--');
// Check if frm.doc is defined and log it
if (!frm || !frm.doc) {
console.error('frm or frm.doc is not defined');
return Promise.reject(new Error('frm or frm.doc is not defined'));
} else {
console.log('frm.doc:', frm.doc);
}
try {
// Get the active workflow for the doctype
let workflow = await get_active_workflow_for_doctype(frm.doc.doctype);
console.log('Active workflow for doctype:', workflow);
// Ensure the workflow object has the necessary properties
if (!workflow || !workflow.name) {
console.error('Invalid workflow object:', workflow);
return Promise.reject(new Error('Invalid workflow object'));
}
return new Promise((resolve, reject) => {
console.log('Calling frappe.call to get transitions--');
frappe.call({
method: 'frappe.model.workflow.get_transitions',
args: {
doc: frm.doc, // The document
workflow_name: workflow.name, // The name of the workflow
raise_exception: true, // Raise exception if no transitions found
},
callback: function(response) {
console.log('Inside callback--');
if (response.message) {
console.log('Transitions FOUND--', response.message);
resolve(response.message);
} else {
console.log('No transitions found--');
reject(new Error(No transitions found for workflow ${workflow.name}));
}
},
error: function(error) {
console.error('Error calling frappe.model.workflow.get_transitions:', error);
reject(error);
}
});
});
} catch (error) {
console.error('Error getting active workflow:', error);
return Promise.reject(error);
}
}
Console logs-
giving Transitions FOUND-- []
transitions determine_workflow_action are-- []
No workflow action found for the current state and conditions
but in “tabWorkflow Transition” it has transitions
is there anything I am missing?
have tried with workflow object in parameter workflow but getting error -
AttributeError: ‘str’ object has no attribute ‘workflow_state_field’