Personalizar envío de notificaciones

Veréis que al agregar una pill tenéis la opción de "Notificar". Esto envía una notificación por defecto a los usuarios seleccionados

Para personalizar esta notificación realizaremos los siguientes pasos:

1 - Crear un scrit en zmi/portal_skins/custom. (podéis utilizar cualquier nombre de script)
2 - Parámetros de entrada : ob,project,notif,field,translate,_=None,usernames=''
3 - Contenido orientativo del script :

if not ob:
return False

proxy = ob
dm = ob.getContent().getDataModel()
project_dm = project.getContent().getDataModel()
utool = context.portal_url

subject = "Mi Subject"
if not usernames:
usernames = dm['notify_to']

mfrom=''
member = dm['member']
remitente = ''
if member:
brains = catalog(username=member)
if len(brains):
remitente = brains[0].Title
aux = brains[0].getObject().getContent().getDataModel()
if aux['email']:
mfrom = aux['email']

url = utool.getRelativeContentURL(proxy)
if '__' in url:
url = '/'.join(url.split('/')[:-1])

body = """
Aquí va el texto del cuerpo del mensaje, donde podemos adjuntar todos los datos
obtenidos
"""

notif.notifyUsersFromIds(members_ids=usernames, subject=subject, body=body,related_path='',mfrom=mfrom,send_notification_url=False)
something_done = True
return True

4 - Finalmente damos una propiedad a nivel de site (zmi , pestaña properties) , llamada : "custom_skin_for_sendNotifications", del tipo string, y le daremos el nombre de nuestro script

a partir de ahí, las notificaciones enviadas con un campo del tipo KMKey Notification Field, utilizarán este custom script




Etiquetas: