This topic is locked

Notification Link for Master Record after updating linked Table

2/4/2022 9:25:27 PM
PHPRunner General questions
P
Pauldee author

Hi

I've created a notification on a linked table as follows:

addNotification( $message, $title, $icon, $link = null, $expire = null, $clientUsername, $provider = null );

All variables have been set and the above works perfectly.

However, this notification has been created in a linked table and I'm trying to define $link = makePageLink( "Tasks", "edit", $keys); to relate to my master table.

The value of $keys needs to relate to my master table so that the notification can be clicked and the user taken to the edit page of the record. I cannot work out whether this is possible.

I have obatined the row ID on the master table but struggling to get any further.

Any help would be great.

Thanks
Paul

Sergey Kornilov admin 2/6/2022

The terminology like "notification has been created in a link table" doesn't really make much sense as notification is just a notification, it doesn't belong to any table and can point to any URL or doesn't even have to point anywhere. Anyway, I think you are looking for a way to access master table data. Check getMasterRecord() function for this purpose.

P
Pauldee author 2/6/2022

I have a master table called 'Tasks' and a linked table called 'Notes'.

I can use the addNotification function in 'After Recored Added' in the 'Tasks' table as follows:

$message = "New job created.";
$title = "Location: ".$values['Location'];
$icon = "fa-envelope";
$link = makePageLink( "Tasks", "edit", $keys);
$user = "Paul Dee";

addNotification( $message, $title, $icon, $link, $expire = null, $user, $provider = null );

This creates a record in the 'db_noti' table as follows (amongst other fields):

url: Tasks_edit.php?editid1=5712...

The above works perfectly in the 'After Recored Added' of the master table 'Tasks', all other fields in 'db_noti' table are as expected.

In 'After Recored Added' event of the 'Notes' table, if I use the same code, the url does not contain the ID of the master table:

url: tasksclient_edit.php?editid1=...

Therefore the above url does not point to the edit record of the intended record ID in 'Tasks'.

Hope this makes more sense.

As a workaround, I've created an INSERT directly into the 'bd_noti' table to give me the desired result.

Paul

Sergey Kornilov admin 2/8/2022

Of the same code won't work exactly the same in a different event.

$link = makePageLink( "Tasks", "edit", $keys);

You need to check makePageLink function desctiption. $keys array must point to the required record. If you are in the details table event then $keys array points to the details record. You need to specify master table record info there. Like I said, Check getMasterRecord() function for this purpose.