Forum OpenACS Development: How do I use notifications?

Collapse
Posted by Jade Rubick on
I've been trying to use notifications for project-manager, instead of "rolling my own" notifications.

There are several sources of information on how to use notifications, but no official documentation at this point:

Notifications tutorial - https://openacs.org/forums/message-view?message_id=108283

Bug to add in notifications docs - https://openacs.org/bugtracker/openacs/com/notifications/bug?bug%5fnumber=573

Original docs for notifications - http://web.archive.org/web/20020625161109/http://dotlrn.openforce.net/doc/notifications.adp

I'm having some problems getting notifications to do anything at all. It seems like calls like the following:

        notification::new \
            -type_id [notification::type::get_type_id \
                          -short_name task_added_notif] \
            -object_id $p_id \
            -response_id null \
            -notif_subject $subject \
            -notif_text $notification_text

don't do anything at all, including throw an error. I've tried using the OACSH in developer support, and I get errors like this:

ERROR:
Too many positional parameters specified
    while executing
"new__arg_parser"
    (procedure "notification::new" line 1)
    invoked from within
"notification::new \
"
    ("uplevel" body line 1)
    invoked from within
"uplevel $script"

but that looks like a problem with the backslashes or something, and I'm not getting any errors in my log file, just no notifications.

I also am not getting anything done in the notifications tables. The notification type is added in, but nothing else seems to be added in after the notification::new call.

Any advice here? Also, the notifications tutorial says to use user_id for object_id. Is that right?

Collapse
Posted by Jade Rubick on
I think I figured it out.

You have to create a notification request before a new notification when you're making an instant notification:

        notification::request::new \
            -type_id [notification::type::get_type_id -short_name task_added_notif] \
            -object_id $p_id \
            -user_id $user_id \
            -interval_id [notification::interval::get_id_from_name -name instant] \
            -delivery_method_id [notification::delivery::get_id -short_name email]

I follow this with the notification::new portion above.