![]() |
ChatGPT 6/19/2025 |
It sounds like you're trying to update a field in a detail table based on a value from the master table in PHPRunner, but you're encountering the issue where Here are a few steps to troubleshoot and possibly resolve your issue:
Here’s a simple example of how you might implement this:
|
M
|
Mallorca1 author 6/19/2025 |
I tried all this and other sulutions from geminiAI but not working, I always just get the first record of the table which is master with getMasterRecord(). Lookup will not work since the detail table has not enough info to find the exact master record. |
C
|
copper21 6/19/2025 |
If the button you are putting is in the row (grid) of the child list page, then this works for me when viewing the child list page from the master page: Server Tab of button: $record = $button->getMasterRecord(); $sql1 = DB::PrepareSQL("SELECT * FROM MasterTable WHERE PrimaryKey = :1", $record['ID']); This should return the data from the master table for that specific record. You will have to change "MasterTable" with the table name, "PrimaryKey" with your primary key field, and "ID" with the name of your primary field name. |
M
|
Mallorca1 author 6/20/2025 |
Unfortunately also this is not working since getMasterRecord() is not outputing the data which is displayed in the master it is always outputing the first row of the table of the master. This Button (Server code) I have in the row of the detail list page: $record1 = $button->getMasterRecord(); $datavalues = array(); $record2 = $button->getCurrentRecord(); $keyvalues = array(); DB::Update("briefings", $datavalues, $keyvalues); /// Alternative this is having the same result: $record1 = $button->getMasterRecord(); $datavalues = array(); $record2 = $button->getCurrentRecord(); $keyvalues = array(); DB::Update("briefings", $datavalues, $keyvalues); |
C
|
copper21 6/20/2025 |
I think I understand what you are trying to do. I wrote this: //Get Master Record ID & Master Data //You Don't Need This If You Just Need Master Record Primary Key //Get Child Record Data $data3 = array(); If all you need is the master primary key, then you don't need to use the 3 lines of code under "//You Don't Need....." $record2 will get your child record's primary key. If all you need to do is update the "appointmentid" field in the child table, with the primary key of the master table, this should work. Make sure the button is in the grid/row.
Make sure that the child and master tables are connected in the "Tables" section. |
M
|
Mallorca1 author 6/21/2025 |
Thank you but still I just get the id of the first row of the master table not the id of the displayed row of the master table. More details: |
M
|
Mallorca1 author 6/25/2025 |
Since I could not find to solve it another way, I used the Session Variables. But yes, this will make a problem if someone opens a second tab. |
C
|
copper21 6/25/2025 |
Can you send a screen shot of the button and where you have it on the list page? Like previously mentioned, it seems like you have it on the list page of the child table, which is connected to the parent table. I am just trying to figure out why you are getting the first record every time. I have encountered something similar, but that was a long time ago and certainly don't remember what the solution was. |
M
|
Mallorca1 author 6/28/2025 |
Thank you!
|
C
|
copper21 6/30/2025 |
Mallorca1, Thank you for the screenshot. The one thing that I noticed right away is that the "Master table info" snippet that PHPR puts in when two tables are connected isn't on your child/details table you are showing. I am guessing that might have to be there in order to get the correct ID from the master table.
|
M
|
Mallorca1 author 7/1/2025 |
Thank you I also had this bevore but it's not changing anything. I always get the data of the first record of the table, not the one which is displayed on the main. Is maybe this a problem: I have three other child/detail tables on this page all jsut connected to the master and not to each other. |
M
|
Mallorca1 author 7/2/2025 |
Please find the screenshot of the master here. |
![]() |
Tandy 7/4/2025 |
What about joining the fields you want. On mine I listed fields that I want to see on details joined? Do not know if that will help but it did in my case. |
A
|
AbriaCloud 7/8/2025 |
I am having a similar issue in that I resorted to using a session variable to determine the master record. It is a very reliable method. However, as mentioned earlier, the session key is being retrieved from the last opened tab, rather than the detail list row where the button is clicked. The session variable option would work - IF you permit only one detail list to be shown at a time in the master list. Click a new one, close all the others. How would you accomplish this? If you click on a detail row expansion option (hamburger icon, javascript request, etc.), how do you close all other detail lists on the same master listing? As far as I can tell, there is no trigger when a expansion of detail rows is selected. |