diff --git a/frappe/__init__.py b/frappe/__init__.py
index 8e6aaf71af..1144b228c0 100644
--- a/frappe/__init__.py
+++ b/frappe/__init__.py
@@ -347,26 +347,10 @@ def msgprint(msg, title=None, raise_exception=0, as_table=False, as_list=False,
return
if as_table and type(msg) in (list, tuple):
-
- table_rows = ''
- for row in msg:
- table_row_data = ''
- for data in row:
- table_row_data += '
{} | '.format(data)
- table_rows += '{}
'.format(table_row_data)
-
- out.message = ''''''.format(table_rows)
+ out.as_table = 1
- if as_list and type(msg) in (list, tuple):
- if len(msg) > 1:
- list_rows = ''
- for row in msg:
- list_rows += '{}'.format(row)
-
- out.message = ''''''.format(list_rows)
- elif len(msg) == 1:
- out.message = msg[0]
+ if as_list and type(msg) in (list, tuple) and len(msg) > 1:
+ out.as_list = 1
if flags.print_messages and out.message:
print(f"Message: {repr(out.message).encode('utf-8')}")
diff --git a/frappe/public/js/frappe/ui/messages.js b/frappe/public/js/frappe/ui/messages.js
index c37cc41650..bf1b13b424 100644
--- a/frappe/public/js/frappe/ui/messages.js
+++ b/frappe/public/js/frappe/ui/messages.js
@@ -128,6 +128,19 @@ frappe.msgprint = function(msg, title, is_minimizable) {
data.indicator = 'blue';
}
+ if (data.as_list) {
+ const list_rows = data.message.map(m => `${m}`).join('');
+ data.message = ``;
+ }
+
+ if (data.as_table) {
+ const rows = data.message.map(row => {
+ const cols = row.map(col => `${col} | `).join('');
+ return `${cols}
`
+ }).join('');
+ data.message = ``;
+ }
+
if(data.message instanceof Array) {
data.message.forEach(function(m) {
frappe.msgprint(m);