Add Route History Fucntionality To Custom Buttons

I have Student Doctype with View Result Button and Teacher Salary Doctype with Download Salary Slip Button. How can add the click to the log in route history.
Thank you in advance.

Hi @Parth_Vashista,

Means, Route History?

Or Activity Log?


i mean route history

You want, when you click the button and then redirect to the Route History Page, Right?

So basically route history is a log for all the places in the erp the user travelled to and clicked. I want when the student clicks on view result i get something like this logged automatically.

here View_result is the name of my button , Student Application is the doctype and User is the current sessions user

we get similar route history automatically created when we click on the print button

Hi @Parth_Vashista,

We did create some scenarios like:
When the user clicks on the view log button then automatically will create Route History.

Code:

frappe.ui.form.on('Item', {
    refresh: function(frm) {
        frm.add_custom_button(__('View Log'), function() {
            frappe.db.insert({
                'doctype': 'Route History',
                'route': "app/Item/"+frm.doc.name,
                'user':frappe.session.user
            });
        });
    }
});

Please set your data and logic according to.

I hope this helps.
Thank You!

Thank you for the reply !! Is there a way to show the creation field(creation date and time) in route history ?

That for, you should create a custom field in Route History and add the logic for it.

Thanks!

Done created a new field date_time


@frappe.whitelist()
def deferred_insert(routes):
	routes = [
        {
            "user": frappe.session.user,
            "route": route.get("route"),
            "creation": route.get("creation"),
	    	"date_time":route.get("creation"),
        }
        for route in frappe.parse_json(routes)
    ]
	for route in routes:
		doc = frappe.new_doc("Route History")
		doc.update(route)
		doc.save(ignore_permissions=True)

Is there a way to add route history for Save , Update and Delete

Reference: