Redirect after saving Frappe CRM

hello,

I’m having a problem. I created a server script that changes the name of the Deals. It works fine, but after saving the new name, I have to manually navigate to the Deals list view page.
I’m trying to create a CRM form script to automatically redirect after saving the opportunity name. Here is my code:

function setupForm({ doc, router }) {
    return {
        actions: [],  
        afterSubmit() {
            if (doc.custom_deal_name && doc.name !== doc.custom_deal_name) {
                router.push("/crm/deals/view");
            }
        }
    };
}

I also tried using the afterSave() function, but it didn’t work.
Any suggestions for this action?

thanks

Solution!!

After checking the official documentation, I made a change using the Custom actions method, and everything worked perfectly.

https://docs.frappe.io/crm/custom-actions

1 Like