Dialog API
Frappe provides a group of standard, interactive and flexible dialogs that are easy to configure and use. There's also a more extensive API for Javascript.
frappe.msgprint
frappe.msgprint(msg, title, raise_exception, as_table, as_list, indicator, primary_action, is_minimizable, wide, realtime)
This method works only within a request / response cycle. It shows a message to the user logged in to Desk who initiated the request.
The argument list includes:
msg: The message to be displayedtitle: Title of the modalas_table: Ifmsgis a list of lists, render as HTML tableas_list: Ifmsgis a list, render as HTML unordered listprimary_action: Bind a primary server/client side action.raise_exception: Exceptionis_wide: Show a wide modalis_minimizable: Allow users to minimize the modalrealtime: publish immediately using websocket instead of adding to response message log
frappe.msgprint(
msg='This file does not exist',
title='Error',
raise_exception=FileNotFoundError
)
frappe.msgprint
primary_action can contain a server_action or client_side action which must contain dotted paths to the respective methods. The JavaScript function must be a globally available function. You can also pass hide_on_success to close the message after the action is successfully completed.
# msgprint with server and client side action
frappe.msgprint(msg='This file does not exist',
title='Error',
raise_exception=FileNotFoundError
primary_action={
'label': _('Perform Action'),
'server_action': 'dotted.path.to.server.method',
'client_action': 'dotted.path.to.client.method',
'hide_on_success': True,
'args': args
}
)
frappe.msgprint with primary action
frappe.throw
frappe.throw(msg, exc, title, is_minimizable, wide, as_list, primary_action)
This method will raise an exception as well as show a message in Desk. It is essentially a wrapper around frappe.msgprint.
exc can be passed an optional exception. By default it will raise a ValidationError exception.
frappe.throw(
title='Error',
msg='This file does not exist',
exc=FileNotFoundError
)
frappe.throw