Repository: frappe/frappe

Issue:
Custom Page Redirection in Notifications
<!--
Welcome to the Frappe Framework issue tracker! Before creating an issue, please heed the following:

1. This tracker should only be used to report bugs and request features / enhancements to Frappe
    - For questions and general support, refer to https://stackoverflow.com/questions/tagged/frappe
    - For documentation issues, use https://frappeframework.com/docs/user/en or the developer cheetsheet https://frappeframework.com/docs/user/en/bench/resources/bench-commands-cheatsheet
2. Use the search function before creating a new issue. Duplicates will be closed and directed to
   the original discussion.
3. When making a feature request, make sure to be as verbose as possible. The better you convey your message, the     greater the drive to make it happen.
-->

Is your feature request related to a problem? Please describe.
Allow redirection to custom URL on notification click.

Describe the solution you'd like
Currently, in the Frappe framework, notifications only support a default redirection mechanism to a particular doctype.

We should have ability to specify:

portal URL (custom app like desk has some notification)
Framework page 
Kanban link or something like that

Suggested Changes:

1. We will add “Custom Link” in type
2. We will have another field called “Link Uri” where we will store the custom link.
3. We will check if it is “Custom Link”. If it is Custom Link then we will Open the specified link instead of Opening Reference Document
4. We will specify the

Example use case:

We are having a custom  WhatsApp-like which is built inside the framework, we want the user to be directed to a custom page in Frappe when they click on a notification (which is linked to whatsapp message), rather than the standard WhatsApp message doctype.



Discussion:

Resolving patch:
diff --git a/frappe/desk/doctype/notification_log/notification_log.py b/frappe/desk/doctype/notification_log/notification_log.py
--- a/frappe/desk/doctype/notification_log/notification_log.py
+++ b/frappe/desk/doctype/notification_log/notification_log.py
@@ -25,6 +25,7 @@ class NotificationLog(Document):
 		email_content: DF.TextEditor | None
 		for_user: DF.Link | None
 		from_user: DF.Link | None
+		link: DF.Data | None
 		read: DF.Check
 		subject: DF.Text | None
 		type: DF.Literal["Mention", "Energy Point", "Assignment", "Share", "Alert"]
@@ -125,21 +126,24 @@ def send_notification_email(doc):
 	if not email:
 		return
 
-	doc_link = get_url_to_form(doc.document_type, doc.document_name)
 	header = get_email_header(doc)
 	email_subject = strip_html(doc.subject)
+	args = {
+		"body_content": doc.subject,
+		"description": doc.email_content,
+	}
+	if doc.link:
+		args["doc_link"] = doc.link
+	else:
+		args["document_type"] = doc.document_type
+		args["document_name"] = doc.document_name
+		args["doc_link"] = get_url_to_form(doc.document_type, doc.document_name)
 
 	frappe.sendmail(
 		recipients=email,
 		subject=email_subject,
 		template="new_notification",
-		args = {
-			"body_content": doc.subject,
-			"description": doc.email_content,
-			"document_type": doc.document_type,
-			"document_name": doc.document_name,
-			"doc_link": doc_link,
-		},
+		args=args,
 		header=[header, "orange"],
 		now=frappe.flags.in_test,
 	)


Test patch: